🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++.leda
Article #42

problem with node priority queue

#42
From: Matthew David Scruggs
Date: Wed, 16 Aug 1995 14:08
38 lines
1439 bytes
I have code similar to the following(everything's declared, etc):

int foo(graph &G, node_array<double> cost, node_array<node) pred ...)
{

node_pq<double> Q(G);
forall_nodes(n,G) Q.insert(n,cost[n]);

while(!Q.empty()){
  n = Q.del_min();
  if(n){
    forall_adj_nodes(n1,n){
	if(Q.member(n1){
	  cout << index(n1) << " ";
   	  pred[n1] = n;
          ....other stuff.....
	}
    }
  }
}
}

if I pass this function a graph with nodes {a, b, c, d}
where cost[a]<cost[b]<...<cost[d], the a is the minimum
on the first pass, and should be deleted from the node
priority queue Q.  However, "a" shows up as a member of
Q on the next pass (and causes a bus error). "a" is 
assigned to "n" on the first pass.  

Any ideas why?  Any fixes?

Dave  (using LEDA 3.1.2)
--
-----------------------------------------------------------------------
		   Georgia Institute of Technology
      School of Electrical Engineering, Atlanta, GA  30332-0250
		    E-MAIL: scruggs@eecom.gatech.edu
			PHONE: (404) 894-2955
Technical Details
Message-ID: <40su41$mtr@hardy.ee.gatech.edu>
Path: arc1-ca.pugleaf.net!sigloch.eecom.gatech.edu!scruggs

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sigloch.eecom.gatech.edu!scruggs
From: scruggs@ece.gatech.edu (Matthew David Scruggs)
Newsgroups: comp.lang.c++.leda
Subject: problem with node priority queue
Date: 16 Aug 1995 14:08:01 GMT
Organization: School of Electrical and Computer Engineering, Ga Tech
Message-ID: <40su41$mtr@hardy.ee.gatech.edu>
NNTP-Posting-Host: sigloch.eecom.gatech.edu
X-Newsreader: TIN [version 1.2 PL2]