简体   繁体   English

我可以在带有python的Yed-Graphs上使用图形算法吗?

[英]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. 我正在使用Yed绘制一些图形,如下图所示。 Is there a way I can use python to compute a Depth-First exploration on these? 有没有办法可以使用python计算这些深度优先探索? 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). 首先,你从一个基础/ Root开始,然后你可以运行或跳转(c或d)。 Running brings you to point 2, jumping to point 5. The result that I need then is: 跑步带你到第2点,跳到第5点。我需要的结果是:

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. 我只是使用了yed,所以我可以使用图形界面。 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 ). 您可以使用networkx模块(需要安装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. 它可以读取生成的graphml格式,并具有遍历图形的算法。 Have a look at the documentation of it: networkx 看一下它的文档: networkx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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