The creawler lib idea is probably not going to work, crawling and analysing are way too interwined, I have however separated the graph creation part in a file. the function Create_Edge(node,node,typeOfconnection) creates 2 nodes(or edit them) and 1 edge. following are one file that uses the library(graphTest.php) and the library(libGraph.php)
graphTest.php <html> <body> <?php include "libGraph.php"; Create_Edge("node1","node2","relates",FALSE); Create_Edge("node1","node3","Parent_Of"); Create_Edge("node3","node1","Child_Of"); ?> </body> </html> //====================================== //ANOTHER FILE!!!!!!!!!!!!!!!! //libGraph.php //====================================== <?php function Create_Edge($nodeA,$nodeB,$edgeType,$Directed_RETURN_TRIP=TRUE) { mkdir("./graph/"); $nodeAfile= "./graph/".base64_encode($nodeA); if (file_exists($nodeAfile) ) { $fh1= fopen($nodeAfile,"r+"); $raw_node= fread($fh1,filesize($nodeAfile)); $node= unserialize($raw_node); $node[$edgeType][$nodeB]= TRUE; ftruncate($fh1,0); rewind($fh1); fwrite($fh1,serialize($node)); fclose($fh1); } else { $fh1= fopen($nodeAfile,"w"); $node[$edgeType][$nodeB]= TRUE; fwrite($fh1,serialize($node)); fclose($fh1); } $nodeBfile= "./graph/".base64_encode($nodeB); if (!file_exists($nodeBfile) ) { $fh1= fopen($nodeBfile,"w"); fclose($fh1); } if ($Directed_RETURN_TRIP==FALSE) Create_Edge($nodeB,$nodeA,$edgeType,TRUE);//says true, but actually, directed is false in both cases. One could call it round_trip $fLog1= fopen("graph.log","a"); fwrite($fLog1,"Created edge: ".$nodeA."\x19".$edgeType."\x19".$nodeB."\n"); fclose($fLog1); return; } /* Also, create file: nodeA+edgeType+nodeB Todo, separate $Direction and $RoundTrip nodeA[Edge][nodeB]= $Direction(POINTER, ARROW, NONE) if $Direction==NONE and RT==false call create edge, with RT as true */ ?>