Description | Graph generators and utilities related to graphs. |
Header file | LGraphUtil.h |
Author | Stefano Emiliozzi, Camil Demetrescu |
Created | Feb 19, 2003 |
Last updated | Sep 27, 2003 |
Functions |
|
LGraph* LGraphUtil_RandomNM (ui2 n, ui4 m, ui4 inSeed) LGraph* LGraphUtil_RandomUNM (ui2 n, ui4 m, ui4 inSeed) LGraph* LGraphUtil_RandomNP (ui2 n, f4 p, ui4 inSeed) LGraph* LGraphUtil_RandomUNP (ui2 n, f4 p, ui4 inSeed) LGraph* LGraphUtil_Grid (ui2 n, Bool inDirected) LGraph* LGraphUtil_RandomClustered (ui2 n, ui2 inC, f4 inPc, f4 inPi, ui4 inSeed, Bool inDirected) LEdgeInfo* LGraphUtil_RndEdgeInfoUI4 (LGraph* inGraph, ui4 inA, ui4 inB, ui4 inSeed) void LGraphUtil_AddCycle (LGraph** thruGraph) Bool LGraphUtil_LoadDimacs (i1* inPathName, LGraph** outGraph, LEdgeInfo** outEdgeInfo, Bool inDirected) Bool LGraphUtil_SaveDimacs (i1* inPathName, LGraph* inGraph, LEdgeInfo* inEdgeInfo) Bool LGraphUtil_LoadXML (i1* inPathName, LGraph** outGraph, LEdgeInfo** outEdgeInfo, Bool inDirected) Bool LGraphUtil_SaveXML (i1* inPathName, LGraph* inGraph, LEdgeInfo* inEdgeInfo) LGraph* LGraphUtil_PredToTree (LGraph* inGraph, LNodeInfo* inPredArray, LNodeInfo** outTreeToGraph, LNodeInfo** outGraphToTree) LGraph* LGraphUtil_CopyGraph (LGraph* inGraph) LEdgeInfo* LGraphUtil_CopyEdgeInfo (LGraph* inGraph, LEdgeInfo* inEdgeInfo) LGraph* LGraphUtil_ReverseGraph (LGraph* inGraph) void LGraphUtil_RemoveSelfLoops (LGraph** thruGraph) |
Function | Arguments | Description | Returns | Throws |
RandomNM |
ui2 n ui4 m i4 inSeed |
Creates a random directed LGraph with n nodes and m edges. inSeed is the random number generator seed used to create the graph. Caller is responsible of deallocating the created object using LGraph_Delete. |
LGraph* pointer to the newly created graph |
- |
RandomUNM |
ui2 n ui4 m i4 inSeed |
Creates a random undirected LGraph with n nodes and m edges. inSeed is the random number generator seed used to create the graph. Caller is responsible of deallocating the created object using LGraph_Delete. |
LGraph* pointer to the newly created graph |
- |
RandomNP |
ui2 n f4 p i4 inSeed |
Creates a random directed LGraph with n nodes and approx. (p*n^2) edges; p is the probability to have an edge between each pair of nodes. inSeed is the random number generator seed used to create the graph. Caller is responsible of deallocating the created object using LGraph_Delete. |
LGraph* pointer to the newly created graph |
- |
RandomUNP |
ui2 n f4 p i4 inSeed |
Creates a random undirected LGraph with n nodes and approx. (p*n(n-1)/2) edges; p is the probability to have an edge between each pair of nodes. inSeed is the random number generator seed used to create the graph. Caller is responsible of deallocating the created object using LGraph_Delete. |
LGraph* pointer to the newly created graph |
- |
RandomClustered |
ui2 n ui2 inC f4 inPc f4 inPi ui4 inSeed Bool inDirected |
Returns a random LGraph with inN nodes and inC strongly connected clusters. There is an edge in the same cluster with probability inPc, and there is an edge between different clusters with probability inPi. To make sure that clusters are strongly connected, a cycle through all nodes in the cluster is added. Caller is responsible of deallocating the created object using LGraph_Delete. |
LGraph* pointer to the newly created graph |
- |
RndEdgeInfoUI4 |
LGraph* inGraph ui4 inA ui4 inB i4 inSeed |
Creates a random LEdgeInfo associated to given inGraph with ui4 values ranging from inA to inB. Caller is responsible of deallocating the created object using LEdgeInfo_Delete. |
LEdgeInfo* pointer to the newly created LEdgeInfo |
- |
AddCycle | LGraph** thruGraph | Adds a cycle between all nodes in the graph pointed to by *thruGraph. |
void |
- |
LoadDimacs |
i1* inPathName LGraph** outGraph LEdgeInfo** outEdgeInfo |
Loads a file stored in DIMACS format. Puts in outGraph and in outEdgeInfo the pointers to the loaded structures. More information about DIMACS network file formats is available via anonymous ftp from ftp://dimacs.rutgers.edu/pub/netflow/general-info/specs.tex. Caller is responsible of deallocating the created objects using LGraph_Delete and LEdgeInfo_Delete. |
Bool Returns TRUE if the parsing was succesful, FALSE otherwise. |
- |
SaveDimacs |
i1* inPathName LGraph* inGraph LEdgeInfo* inEdgeInfo |
Saves graph inGraph with edge weights inEdgeInfo in a file in DIMACS format. More information about DIMACS network file formats is available via anonymous ftp from ftp://dimacs.rutgers.edu/pub/netflow/general-info/specs.tex. |
Bool Returns TRUE if the saving was succesful, FALSE otherwise. |
- |
LoadXML |
i1* inPathName LGraph** outGraph LEdgeInfo** outEdgeInfo |
Loads a graph from a file stored in XML format. The
file is parsed with the following Document Type Definition: <!DOCTYPE GRAPH [ <!ELEMENT GRAPH (EDGE*)> <!ATTLIST GRAPH label CDATA #IMPLIED nodes CDATA #REQUIRED edges CDATA #REQUIRED> <!ELEMENT EDGE EMPTY> <!ATTLIST EDGE label CDATA #IMPLIED weight CDATA #IMPLIED source CDATA #REQUIRED dest CDATA #REQUIRED> ]> The pointers to the loaded structures are in *outGraph and in *outEdgeInfo. Caller is responsible of deallocating the created objects using LGraph_Delete and LEdgeInfo_Delete. |
Bool Returns TRUE if the parsing was succesful, FALSE otherwise. |
- |
SaveXML |
i1* inPathName LGraph* inGraph LEdgeInfo* inEdgeInfo |
Saves a graph inGraph with edge weights inEdgeInfo
in a file in XML format. The file is structured according to the following
Document Type Definition: <!DOCTYPE GRAPH [ <!ELEMENT GRAPH (EDGE*)> <!ATTLIST GRAPH label CDATA #IMPLIED nodes CDATA #REQUIRED edges CDATA #REQUIRED> <!ELEMENT EDGE EMPTY> <!ATTLIST EDGE label CDATA #IMPLIED weight CDATA #IMPLIED source CDATA #REQUIRED dest CDATA #REQUIRED> ]> |
Bool Returns TRUE if the operation was succesful, FALSE otherwise. |
- |
PredToTree |
LGraph* inGraph LNodeInfo* inPredArray LNodeInfo** outTreeToGraph LNodeInfo** outGraphToTree |
Builds a subtree of inGraph according to predecessor array inPredArray: i.e., the tree has the same nodes as the graph, and there is an edge between node x and node y in the built tree if and only if x == (LGraph_TNode*) LNodeInfo_PtrAt(inPredArray, y). If outTreeToGraph/outGraphToTree are not NULL upon call of the method, *outTreeToGraph will map Tree nodes->Graph nodes and *outGraphToTree will map Graph nodes->Tree nodes. Caller is responsible of deallocating the created objects *outTreeToGraph and *outGraphToTree (if outTreeToGraph/outGraphToTree are not NULL) and the returned new graph using LNodeInfo_Delete and LGraph_Delete. |
LGraph* Pointer to the created subtree |
- |
CopyGraph | LGraph* inGraph | Returns a graph that is the copy of inGraph. Information associated to edges and nodes is not copied. Caller is responsible of deallocating the created object using LGraph_Delete. |
LGraph* Pointer to the created graph |
- |
ReverseGraph | LGraph* inGraph | Returns a new graph obtained from inGraph by reversing the direction of each edge. If inGraph is undirected, the function returns NULL. Caller is responsible of deallocating the created object using LGraph_Delete. |
LGraph* Pointer to the created graph |
- |
RemoveSelfLoops | LGraph** thruGraph | Removes all the self loops in *thruGraph. It works on both undirected and directed graphs. |
void |
- |