python -networkx 基本知识

  图论

平均路径长度:所有可能节点对应的最短路径长度的平均值


nexworkx


图片发自简书App


nx.from_edgelist (el,directed=TRUE)

el:边列表,两列矩阵,字符或者数字

directed:是否创建有向图


nexworkx.find_cliques(G):搜索图中最大团

nx.core_network(graph)  #搜索节点最大k-core

nx.add_edge('顶点u","顶点v")  #向graph中添加边

Graph.has_node(n)Return True if the graph contains the node n.

Graph.__contains__(n)Return True if n is a node, False otherwise.

Graph.has_edge(u, v)Return True if the edge (u,v) is in the graph.

Graph.order()Return the number of nodes in the graph.

Graph.number_of_nodes()Return the number of nodes in the graph.

Graph.__len__()Return the number of nodes.

Graph.degree([nbunch, weight])Return the degree of a node or nodes.

Graph.degree_iter([nbunch, weight])Return an iterator for (node, degree).

Graph.size([weight])Return the number of edges.

Graph.number_of_edges([u, v])Return the number of edges between two nodes.

Graph.nodes_with_selfloops()Return a list of nodes with self loops.

Graph.selfloop_edges([data, default])Return a list of selfloop edges.

Graph.number_of_selfloops()Return the number of selfloop edges.

作者:Forget_ever

链接:https://www.jianshu.com/p/e543dc63454f

来源:简书

简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。



最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容