[英]Equivalent of R igraph graph_from_data_frame() function in Python igraph?
Is there an equivalent of this igraph R function in Python igraph?在 Python igraph 中是否有等效于此 igraph R function的 igraph?
graph_from_data_frame(d, directed = TRUE, vertices = NULL)
graph_from_data_frame(d,定向= TRUE,顶点= NULL)
This function creates an igraph graph from one or two data frames containing the (symbolic) edge list and edge/vertex attributes.
这个 function 从一个或两个包含(符号)边列表和边/顶点属性的数据帧创建 igraph 图。
Python does not have data frames so there is no direct equivalent. Python没有数据框,因此没有直接的等效项。 The closest equivalent could be
Graph.DictList
, which creates a graph from a list of dictionaries, or Graph.TupleList
, which is the same for a list of tuples. 最接近的等效项可以是
Graph.DictList
(从字典列表创建图),或者Graph.TupleList
(与元组列表相同)。
Right now you can use this:现在你可以使用这个:
from igraph import Graph
g = Graph.DataFrame(edges, directed=False, vertices=vertices, use_vids=False)
where "edges" is the dataframe with the edges, vertices are the names that will be used in each vertex, and use_vids if you want to assign indexes to name the edges instead of using the "vertices" data其中“边”是带有边的 dataframe,顶点是将在每个顶点中使用的名称,如果要分配索引来命名边而不是使用“顶点”数据,请使用_vids
https://igraph.org/python/api/0.9.7/igraph.Graph.html#DataFrame https://igraph.org/python/api/0.9.7/igraph.Graph.html#DataFrame
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.