如何在图形中标记特定类型(例如030T)的所有三合会?

问题描述 投票:0回答:1

我有一个数据框df,带有:

Source, Target
aaaa, bbbb
aaaa, cccc
aaaa, dddd
bbbb, cccc
cccc, dddd

依此类推。

文件“ total_edges.csv”(71kb):https://uni-duisburg-essen.sciebo.de/s/WLDD4ytkjekVcIL

[我得到了一个图形对象,根据github问题跟踪器(https://github.com/igraph/python-igraph/issues/253),三合会节点/边缘,但失败了:

import pandas as pd
import igraph as ig

df_edges = pd.read_csv("total_edges.csv")

g = ig.Graph.TupleList(df_edges.itertuples(index=False), directed=True)
tc = g.triad_census()
ffl = ig.Graph.Formula("A --> B --> C, A --> C")
result = g.get_subisomorphisms_lad(ffl, induced=True)
print(result)

错误消息(具有更新的Pop_OS x64,Python 3.7.5的VM:

Traceback (most recent call last):
  File "count_triads.py", line 20, in <module>
    ffl = ig.Graph.Formula("A --> B --> C, A --> C")
  File "/home/admin/.local/lib/python3.7/site-packages/igraph/formula.py", line 209, in construct_graph_from_formula
    for start_names, end_names, arrowheads in generate_edges(part):
  File "/home/admin/.local/lib/python3.7/site-packages/igraph/formula.py", line 90, in generate_edges
    raise SyntaxError(msg)
SyntaxError: invalid token found in edge specification: A --> B --> C

如何为类型为030T的三重轴标记该图中的所有节点的三重轴值(A,B,C,无),以便我可以不同方式过滤/绘制三重轴和非三重轴?

python igraph sna python-igraph
1个回答
0
投票

关于错误,看来您被与此issue in the formula parser相似的问题打中。

尝试应用最新的changesinstalling the development version of python-igraph可能会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.