Structures_Graph indegree method

From: Date: Thu, 02 Mar 2006 12:30:52 +0000
Subject: Structures_Graph indegree method
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-23201@lists.php.net to get a copy of this message
Hi all, I have a question about Structures_Graph package. When I create an arc between two nodes in a directed graph (e.g. from A to B) I expect to have: A outdegree=1 B indegree=1 Instead the indegree method always report: A outdegree=1 B indegree=0 If I make the same nodes connection in an non directed graph (indegree should be equal to outdegree) I obtain: B indegree=0 B outdegree=0 So the be node should be isolated!!! It's a bug or maybe I don't understand how to use this package class? Below you can find a snippet of code and the output: ----------------------------------- require_once 'Structures/Graph.php'; $directedGraph =& new Structures_Graph(true); require_once 'Structures/Graph/Node.php'; $nodeOne =& new Structures_Graph_Node(); $nodeTwo =& new Structures_Graph_Node(); $directedGraph->addNode(&$nodeOne); $directedGraph->addNode(&$nodeTwo); $nodeOne->connectTo($nodeTwo); // Nodes are able to calculate their indegree and outdegree print("NodeOne's outDegree: " . $nodeOne->outDegree()); echo "<br />"; print("NodeTwo's inDegree: " . $nodeTwo->inDegree()); echo "<br />"; ---------------------------------- Output: NodeOne's outDegree: 1 NodeTwo's inDegree: 0 ----------------------------------- Thank you very much, Alessandro -- Alessandro Martin

« previous php.pear.general (#23201) next »