简体   繁体   中英

Can i use a Graph-Algorithm on Yed-Graphs with python?

I am using Yed to paint some graphs as shown in the picture below. Is there a way I can use python to compute a Depth-First exploration on these? I would like the algorithm to protocol the Edges he has traveled and the nodes he visited.

Example graph: 示例图

Edit: I would like to use this method to record actions of people in a sports game. At first you start at a base/Root, then you can run or jump (c or d). Running brings you to point 2, jumping to point 5. The result that I need then is:

1.  root, ([c,2] ,[b,3]), Descript_3 
2.  root, ([c,2] ,[a,4]), Descript_4
3.  root, ([c,2] ,[b,2], [a,4]), Descript_4
...

I am just using yed, so I can use a graphical interface. If there is something better in pure python, I am all up for it. But lets stick to yed for now. Can I get additional attributes to the nodes?

Edit: Since I cannot get this thing to work for myself, I am setting a bounty for an example program. The example program should do the following:

1. Parse the graphml-File and build up the tree
2. Compute all Roundtrip-Path with Node-Coverage
3. write all paths into a table: Name of the node, Text on the arrow

From there I can figure the rest out myself. If its done by using librarys, then that's cool too, but I need to be able to extend it myself. I would also have it to be able to handle graphs, instead of trees.

You can use the networkx module (need to be installed pip install networkx ). This module is a powerfull library for working with graphs. It can read the graphml format which yed produces and has algorithems for traversing a graph. Have a look at the documentation of it: networkx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM