X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=src%2Fpyutils%2Fgraph.py;h=e5966975139296365d284398fd0a97bdd3da051c;hb=cb25f35595b220b0573170954183d6c296d511e5;hp=428dd1650a3e913a3f61248aa8db80424dd8a981;hpb=fcbdf562a6836efe5a62b3990b4129277be6dc94;p=pyutils.git diff --git a/src/pyutils/graph.py b/src/pyutils/graph.py index 428dd16..e596697 100644 --- a/src/pyutils/graph.py +++ b/src/pyutils/graph.py @@ -16,8 +16,7 @@ class Graph(object): """Constructs a new Graph object. Args: - directed: are we modeling a directed graph? See ::meth - add_edge. + directed: are we modeling a directed graph? See :meth:`add_edge`. """ self.directed = directed @@ -56,8 +55,8 @@ class Graph(object): .. note:: - If either or both of src and dest are not already added to the - graph, they are implicitly added by adding this edge. + If either or both of src and dest are not already added to + the graph, they are implicitly added by adding this edge. Args: src: the source vertex id @@ -129,13 +128,15 @@ class Graph(object): Returns: An ordered sequence of vertex ids visited by the traversal. - A ------ B - | | - | | - C ------ D ------ E ------ F -O - | - | - G + .. graphviz:: + + graph g { + node [shape=record]; + A -- B -- D; + A -- C -- D -- E -- F; + F -- F; + E -- G; + } >>> g = Graph() >>> g.add_edge('A', 'B') @@ -181,13 +182,15 @@ class Graph(object): Returns: An ordered sequence of vertex ids visited by the traversal. - A ------ B - | | - | | - C ------ D ------ E ------ F -O - | - | - G + .. graphviz:: + + graph g { + node [shape=record]; + A -- B -- D; + A -- C -- D -- E -- F; + F -- F; + E -- G; + } >>> g = Graph() >>> g.add_edge('A', 'B')