安装文件:
1.python-2.7.3.msi
2.pywin32-214.win32-py2.7.exe
3.numpy-1.6.2.win32-py2.7.exe
4.matplotlib-1.1.0.win32-py2.7.exe
5.setuptools-0.6c11.win32-py2.7.exe
6.networkx-1.7rc1-py2.7.egg
代码片段和文件信息
“““
This module provides functions to convert
NetworkX graphs to and from other formats.
The preferred way of converting data to a NetworkX graph
is through the graph constuctor. The constructor calls
the to_networkx_graph() function which attempts to guess the
input type and convert it automatically.
Examples
--------
Create a 10 node random graph from a numpy matrix
>>> import numpy
>>> a=numpy.reshape(numpy.random.random_integers(01size=100)(1010))
>>> D=nx.DiGraph(a)
or equivalently
>>> D=nx.to_networkx_graph(acreate_using=nx.DiGraph())
Create a graph with a single edge from a dictionary of dictionaries
>>> d={0: {1: 1}} # dict-of-dicts single edge (01)
>>> G=nx.Graph(d)
See Also
--------
nx_pygraphviz nx_pydot
“““
__author__ = “““
“““.join([‘Aric Hagberg (hagberg@lanl.gov)‘
‘Pieter Swart (swart@lanl.gov)‘
‘Dan Schult(dschult@colgate.edu)‘])
# Copyright (C) 2006-2011 by
# Aric Hagberg
# Dan Schult
# Pieter Swart
# All rights reserved.
# BSD license.
import warnings
import networkx as nx
__all__ = [‘to_networkx_graph‘
‘from_dict_of_dicts‘ ‘to_dict_of_dicts‘
‘from_dict_of_lists‘ ‘to_dict_of_lists‘
‘from_edgelist‘ ‘to_edgelist‘
‘from_numpy_matrix‘ ‘to_numpy_matrix‘
‘to_numpy_recarray‘
‘from_scipy_sparse_matrix‘ ‘to_scipy_sparse_matrix‘]
def _prep_create_using(create_using):
“““Return a graph object ready to be populated.
If create_using is None return the default (just networkx.Graph())
If create_using.clear() works assume it returns a graph object.
Otherwise raise an exception because create_using is not a networkx graph.
“““
if create_using is None:
G=nx.Graph()
else:
G=create_using
try:
G.clear()
except:
raise TypeError(“Input graph is not a networkx graph type“)
return G
def to_networkx_graph(datacreate_using=Nonemultigraph_input=False):
“““Make a NetworkX graph from a known data structure.
The preferred way to call this is automatically
from the class constructor
>>> d={0: {1: {‘weight‘:1}}} # dict-of-dicts single edge (01)
>>> G=nx.Graph(d)
instead of the equivalent
>>> G=nx.from_dict_of_dicts(d)
Parameters
----------
data : a object to be converted
Current known types are:
any NetworkX graph
dict-of-dicts
dist-of-lists
list of edges
numpy matrix
numpy ndarray
scipy sparse matrix
pygraphviz agraph
create_using : NetworkX graph
Use specified graph for result. Otherwise a new graph is created.
multigraph_input : bool (default False)
If True and data is a dict_of_dicts
try to create a multigraph assuming dict_of_dict_of_lists.
If data and create_using are bo
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)