首页 > 其他 > 详细

01-igraph简单使用

时间:2020-03-06 11:53:58      阅读:57      评论:0      收藏:0      [点我收藏+]
# coding: utf-8
import igraph
#1.
print(igraph.__version__)#版本
g=igraph.Graph(1)
print(g)#g是图的对象
g.add_vertices(3)#增加3个顶点
print(g)
g.add_edges([(0,1),(1,2),(0,2),(1,3),(0,3),(2,3)])#加边
print(g)

file=open("01.igraphaTest.txt","w")#写入文件
g.write_pajek(file)
file.close()
#IGRAPH U--- 3 3 -- 三个顶点 三个边长

#2.
g=igraph.Graph([(0,2),(0,3),(3,1),(3,4),(3,5),(1,4)])#创建图
print(g)
print(g.degree())#每个点与其他几个点有关系
print(igraph.summary(g))#概述

  

01-igraph简单使用

原文:https://www.cnblogs.com/wcyMiracle/p/12425505.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!