public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH] graph-tool: update to new networkx API, be iterative
@ 2016-08-12 16:23 Ross Burton
  0 siblings, 0 replies; only message in thread
From: Ross Burton @ 2016-08-12 16:23 UTC (permalink / raw)
  To: openembedded-core

Update the dot parser to the new networkx API (using pydotplus to parse).

Also, switch the path display to output the paths as they are found instead of
collecting them into a list, so output appears sooner.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 scripts/contrib/graph-tool | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/scripts/contrib/graph-tool b/scripts/contrib/graph-tool
index 0275fbd..1df5b8c 100755
--- a/scripts/contrib/graph-tool
+++ b/scripts/contrib/graph-tool
@@ -30,8 +30,7 @@ def get_path_networkx(dotfile, fromnode, tonode):
         print('ERROR: Please install the networkx python module')
         sys.exit(1)
 
-    graph = networkx.DiGraph(networkx.read_dot(dotfile))
-
+    graph = networkx.DiGraph(networkx.nx_pydot.read_dot(dotfile))
     def node_missing(node):
         import difflib
         close_matches = difflib.get_close_matches(node, graph.nodes(), cutoff=0.7)
@@ -53,11 +52,11 @@ def find_paths(args, usage):
 
     fromnode = args[1]
     tonode = args[2]
-    paths = list(get_path_networkx(args[0], fromnode, tonode))
-    if paths:
-        for path in paths:
-            print(" -> ".join(map(str,path)))
-    else:
+
+    path = None
+    for path in get_path_networkx(args[0], fromnode, tonode):
+        print(" -> ".join(map(str, path)))
+    if not path:
         print("ERROR: no path from %s to %s in graph" % (fromnode, tonode))
         sys.exit(1)
 
-- 
2.8.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-12 16:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-12 16:23 [PATCH] graph-tool: update to new networkx API, be iterative Ross Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox