参考:ubuntu 下NetworkX的安装和使用

Dependences

  • pip
  • setuptools

Commands

1.install networkx

sudo pip install networkx

2.install numpy & matplotlib (支持networkx绘图)

sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

Run demo

1.新建脚本touch [write_your_name_here].py

2.写入以下内容:

mport networkx as nx

import matplotlib.pyplot as plt

def draw_graph(graph):

    # extract nodes from graph

    nodes = set([n1 for n1, n2 in graph] + [n2 for n1, n2 in graph])

    # create networkx graph

    G=nx.Graph()

    # add nodes

    for node in nodes:

        G.add_node(node)

    # add edges

    for edge in graph:

        G.add_edge(edge[0], edge[1])

    # draw graph

    pos = nx.shell_layout(G)

    nx.draw(G, pos)

    # show graph

    plt.show()

# draw example

graph = [(20, 21),(21, 22),(22, 23), (23, 24),(24, 25), (25, 20)]

draw_graph(graph)

3.执行脚本文件:

sudo python graph.py

Result

2017/1/8

Ubuntu 安装 networkx的更多相关文章

  1. Mac OS、Ubuntu 安装及使用 Consul

    Consul 概念(摘录): Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置.与其他分布式服务注册与发现的方案,比如 Airbnb 的 SmartStac ...

  2. ubuntu安装mysql

    好记性不如烂笔头,记录一下,ubuntu安装mysql的指令. 安装MySQL: sudo apt-get install mysql-server sudo apt-get install mysq ...

  3. ubuntu安装vim时提示 没有可用的软件包 vim,但是它被其它的软件包引用了 解决办法

    ubuntu安装vim时提示 没有可用的软件包 vim-gtk3,但是它被其它的软件包引用了 解决办法 本人在ubuntu系统安装vim  输入 sudo apt-get install vim 提示 ...

  4. docker 1.8+之后ubuntu安装指定版本docker-engine

    这边记录ubuntu安装过程,首先是官网文档 If you haven’t already done so, log into your Ubuntu instance. Open a termina ...

  5. debian/ubuntu安装桌面环境

    apt-get install xorg apt-get install gnome 然后startx ubuntu 安装Gnome桌面 1.安装全部桌面环境,其实Ubuntu系列桌面实际上有几种桌面 ...

  6. 一个ubuntu phper的自我修养(ubuntu安装)

    ubuntu安装篇 一.ubuntu下载 到ubuntu官网下载适合自己电脑配置的系统版本,此处不做展开. 二.制作USB启动盘 在windows下制作USB启动盘,工具是universal usb ...

  7. ubuntu 安装JAVA jdk的两种方法:

    ubuntu 安装jdk 的两种方式: 1:通过ppa(源) 方式安装. 2:通过官网下载安装包安装. 这里推荐第1种,因为可以通过 apt-get upgrade 方式方便获得jdk的升级 使用pp ...

  8. [其他]Ubuntu安装genymotion后unable to load VirtualBox engine

    问题: Ubuntu安装genymotion后unable to load VirtualBox engine 解决办法: 如果没有安装VirtualBox,要先安装VirtualBox. 安装Vir ...

  9. Ubuntu安装出现左上角光标一直闪解决方式

    Ubuntu安装出现左上角光标一直闪解决方式: 01下载ubunu http://cn.ubuntu.com/download/ 02.软碟通 http://pan.baidu.com/s/1qY8O ...

随机推荐

  1. mysql数据库基本知识,简单框架

    https://www.cnblogs.com/geaozhang/p/7347950.html

  2. Python进阶知识

    装饰器 迭代器 生成器 mixins 元编程 描述符 量化领域常用 列表推导式 字典推导式 高阶函数 lambda函数 三目表达式

  3. TestLink安装手册

    环境准备 系统CentOS Linux release 7.3.1611 (Core) 搭建LAMP所需的集成包 xampp-linux-x64-7.2.0-0-installer.run 下载地址 ...

  4. jumpserver(0.3.2版本)开源跳板机系统部署

    1. 介绍 JumpServer亮点: 集成Ansible,批量执行命令: 支持WebTerminal wiki地址:https://github.com/jumpserver/jumpserver/ ...

  5. javaweb前后台中文参数乱码

    一.描述 从前台传中文参数到后台,发现中文乱码. 二.解决 首先,统一所有文件为utf-8格式. 其次,在传参时,使用js的encodeURI函数,对参数进行编码. 然后一定要对该中文参数进行两次编码 ...

  6. python爬虫防止IP被封的一些措施

    在编写爬虫爬取数据的时候,因为很多网站都有反爬虫措施,所以很容易被封IP,就不能继续爬了.在爬取大数据量的数据时更是瑟瑟发抖,时刻担心着下一秒IP可能就被封了. 本文就如何解决这个问题总结出一些应对措 ...

  7. 汉字转换为拼音的JavaScript库

    将JSPinyin剥离mootools这个JavaScript库,可以独立使用. 1)一个是将汉字翻译为拼音,其中每一个字的首字母大写: pinyin.getFullChars(this.value) ...

  8. 20165324 《Java程序设计》 第六周

    学号 2016-2017-2 <Java程序设计>第六周学习总结 教材学习内容总结 第八章 常用实用类 String类 构造String对象:常量对象:String对象:引用String常 ...

  9. Extjs添加行双击事件

    var grid = new Ext.grid.GridPanel({ store: store, trackMouseOver: false, disableSelection: true, aut ...

  10. Java 写文件实现换行

    第一种: 写入的内容中利用\r\n进行换行 File file = new File("D:/text"); try { if(!file.exists()) file.creat ...