- Inherits from:
- Object
- Declared in:
- DGraph.h
Object
|
+---DGraph
Class Description
The graph collection stores objects in directed graph with nodes and edges.
Both the nodes as the edges can store objects. The graph collection can also
be used as graph data structure. Using the toDot method, the graph structure can
be exported to a dot-file which can be visualized with the software of
www.graphviz.org. IMPORTANT: the node and edge objects are owned by the graph
object. Do NOT free them outside the scope of the graph object.
- Last modified:
- 23-Jul-2006 (DGraph.h)
Instance Variables
- private DList *_nodes
- the list with the graph nodes
- private DList *_edges
- the list with the edges
- private DText *_attributes
- the optional (graphviz) attributes
- private long _nodeCounter
- the node counter (for the node name)
- private long _edgeCounter
- the edge counter (for the edge name)
- Constructors
- - (DGraph *) init
- Initialise an empty graph
- Returns:
- the object
- - (DGraph *) init :(const char *) attributes
- Initialise a graph with attributes
- Parameters:
- attributes - the (graphviz) attributes
- Returns:
- the object
- Copy related methods
- - deepen
- Deepen the copied graph
- Returns:
- the object
- - shallowCopy
- Do a shallow copy of the graph
- Returns:
- the object
- Destructor
- - free
- Free the graph (the stored objects are freed)
- Returns:
- the object
- - shallowFree
- Free the graph (the stored objects are NOT freed)
- Returns:
- the object
- Member methods
- - (const char *) attributes
- Return the (graphviz) attributes of the graph
- Returns:
- the attributes (or NULL)
- - (DGraph *) attributes :(const char *) attributes
- Set the (graphviz) attributes for the graph
- Parameters:
- attributes - the attributes (or NULL)
- Returns:
- the graph object
- Main methods
- - (BOOL) addEdge :(DGraphEdge *) edge :(DGraphNode *) source :(DGraphNode *) target
- Add a (new) edge to the graph (graph is the owner of the edge object)
- Parameters:
- edge - the graph edge
source - the source node
target - the target node
- Returns:
- success
- - (DGraphEdge *) addEdge :(const char *) label :(const char *) attributes :(double) weight :(id) object :(DGraphNode *) source :(DGraphNode *) target
- Add a (new) edge to the graph (graph is the owner of the edge object)
- Parameters:
- label - the label for the edge (or NULL)
attributes - the attributes for the edge (or NULL)
weight - the weight for the edge
object - the object for the edge (or nil)
source - the source node
target - the target node
- Returns:
- the (new) edge object (or nil)
- - (BOOL) addNode :(DGraphNode *) node
- Add a (new) node to the graph (graph is the owner of the node)
- Parameters:
- node - the graph node
- Returns:
- success
- - (DGraphNode *) addNode :(const char *) label :(const char *) attributes :(id) object
- Add a (new) node to the graph (graph is the owner of the node)
- Parameters:
- label - the label for the node (or NULL)
attributes - the attributes for the node (or NULL)
object - the object for the node (or nil)
- Returns:
- the (new) node object
- - (BOOL) hasEdge :(DGraphEdge *) edge
- Check if the graph has an edge
- Parameters:
- edge - the graph edge
- Returns:
- has it ?
- - (BOOL) hasNode :(DGraphNode *) node
- Check if the graph has a node
- Parameters:
- node - the graph node
- Returns:
- has it ?
- - (id) removeEdge :(DGraphEdge *) edge
- Remove an edge from the graph (auto disconnect)
- Parameters:
- edge - the edge node
- Returns:
- the object stored in the edge (or nil)
- - (id) removeNode :(DGraphNode *) node
- Remove an node from the graph (node must be unconnected)
- Parameters:
- node - the graph node
- Returns:
- the object stored in the node (or nil)
- - (BOOL) reroute :(DGraphEdge *) edge :(DGraphNode *) source :(DGraphNode *) target
- Reroute an existing edge in the graph
- Parameters:
- edge - the edge
source - the new source for the edge
target - the new target for the edge
- Returns:
- success
- - (DList *) shortestPath :(double *) weight :(DGraphNode *) from :(DGraphNode *) to
- Determine the shortest path between two nodes; a (new) list with REFERENCES
to the nodes in the shortest path are returned; IMPORTANT: free this list
with shallowFree
- Parameters:
- from - the start node
to - the end node
weight - the destination for the path weight (or NULL)
- Returns:
- a (new) list with REFERENCES to the nodes in the shortes path (or nil)
- Iterators
- - (DListIterator *) edges
- Return a (new) iterator on all the edges in the graph
- Returns:
- a (new) list iterator
- - (DListIterator *) nodes
- Return a (new) iterator on all the nodes in the graph
- Returns:
- a (new) iterator
- Export methods
- - (BOOL) toDot :(id <DTextWritable>) writer
- Export to DOT
- Parameters:
- writer - the output object
- Returns:
- success ?
generated 25-Jul-2006 by ObjcDoc 3.0.0