Trees | Indices | Help |
---|
|
The base Graph object implements a simple nodes and edges graph. Nodes - Nodes consist of a dicionary of properties about that node and a unique id which identifies the node in the current graph. From API perspective a node is a tuple of (nodeid, nodeprops). Edges - Edges are directional sets of a from node-id and to node-id and a piece of arbitrary edge information.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Get the list of edges in the graph. Edges are defined as (eid, fromid, toid, einfo) tuples. Example: for eid, fromid, toid, einfo in g.getEdges(): |
Get the (eid, fromid, toid, einfo) tuple for the specified edge. Example: e = g.getEdge(eid) |
Get a property about an edge specified by from/to id. Example: n = g.getEdgeInfo(eid 'name', 'Default Name') |
Set a key/value pair about a given edge by it's from/to id. Example: g.setEdgeInfo(eid, 'awesomeness', 99) |
Store a piece of information (by key:value) about a given node. Example g.setNodeInfo(nid, 'Description', 'My Node Is Awesome!') |
Retrieve a piece of information about a given node by key. Example: descr = g.getNodeInfo(nid, 'Description', default='OH HAI') |
Get the node info dictionary for the specified node. Example: d = g.getNodeProps(nid) |
Add a Node object to the graph. Returns the nodeid. Example: nid = g.addNode() g.addNode('woot', {'height':20, 'width':20}) NOTE: If nodeid is unspecified, it is considered an 'anonymous' node and will have an ID automagically assigned. |
Check if a given node is present within the graph. Example: if g.hasNode('yermom'): print 'woot' |
Add an edge to the graph. Edges are directional. Example: g.addEdge(node_1, node_2, einfo={'name':'Woot Edge'}) |
Delete an edge from the graph (by eid). Example: g.delEdge(eid) |
Return a list of edges which originate with us. Example: for eid, fromid, toid, einfo in g.getRefsFrom(id) |
Return a list of edges which terminate at us. Example: for eid, fromid, toid, einfo in g.getRefsFrom(id) |
Return a list of the subgraph clusters (as graphs) contained within this graph. A subgraph "cluster" is defined as a group of interconnected nodes. This can be used to split out grouped subgraphs from within a larger graph. |
Search for the shortest path from one node to another with the option to filter based on edges using edgecb. edgecb should be a function: def myedgecb(graph, eid, fromid, toid, depth) which returns True if it's OK to traverse this node in the search. Additionally, toid may be None and the caller may specify tocb with a function such as: def mytocb(graph, nid) which must return True on finding the target node Returns a list of edge ids... |
Search from the specified node (breadth first) until you find a node where nodecb(graph, nid) == True. See pathSearchFromTo for docs on edgecb... |
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Nov 16 18:22:13 2012 | http://epydoc.sourceforge.net |