本文整理汇总了Python中networkx.cubical_graph函数的典型用法代码示例。如果您正苦于以下问题:Python cubical_graph函数的具体用法?Python cubical_graph怎么用?Python cubical_graph使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cubical_graph函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_periodic
def test_periodic(self):
G = nx.grid_2d_graph(0, 0, periodic=True)
assert_equal(dict(G.degree()), {})
for m, n, H in [(2, 2, nx.cycle_graph(4)), (1, 7, nx.cycle_graph(7)),
(7, 1, nx.cycle_graph(7)),
(2, 5, nx.circular_ladder_graph(5)),
(5, 2, nx.circular_ladder_graph(5)),
(2, 4, nx.cubical_graph()),
(4, 2, nx.cubical_graph())]:
G = nx.grid_2d_graph(m, n, periodic=True)
assert_true(nx.could_be_isomorphic(G, H))
开发者ID:jklaise,项目名称:networkx,代码行数:12,代码来源:test_lattice.py
示例2: test_labels_and_colors
def test_labels_and_colors(self):
G = nx.cubical_graph()
pos = nx.spring_layout(G) # positions for all nodes
# nodes
nx.draw_networkx_nodes(G, pos,
nodelist=[0, 1, 2, 3],
node_color='r',
node_size=500,
alpha=0.8)
nx.draw_networkx_nodes(G, pos,
nodelist=[4, 5, 6, 7],
node_color='b',
node_size=500,
alpha=0.8)
# edges
nx.draw_networkx_edges(G, pos, width=1.0, alpha=0.5)
nx.draw_networkx_edges(G, pos,
edgelist=[(0, 1), (1, 2), (2, 3), (3, 0)],
width=8, alpha=0.5, edge_color='r')
nx.draw_networkx_edges(G, pos,
edgelist=[(4, 5), (5, 6), (6, 7), (7, 4)],
width=8, alpha=0.5, edge_color='b')
# some math labels
labels = {}
labels[0] = r'$a$'
labels[1] = r'$b$'
labels[2] = r'$c$'
labels[3] = r'$d$'
labels[4] = r'$\alpha$'
labels[5] = r'$\beta$'
labels[6] = r'$\gamma$'
labels[7] = r'$\delta$'
nx.draw_networkx_labels(G, pos, labels, font_size=16)
plt.show()
开发者ID:ProgVal,项目名称:networkx,代码行数:34,代码来源:test_pylab.py
示例3: test_cubical
def test_cubical(self):
G = nx.cubical_graph()
assert_equal(list(nx.square_clustering(G).values()),
[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5])
assert_equal(list(nx.square_clustering(G,[1,2]).values()),[0.5, 0.5])
assert_equal(nx.square_clustering(G,[1])[1],0.5)
assert_equal(nx.square_clustering(G,[1,2]),{1: 0.5, 2: 0.5})
开发者ID:AmesianX,项目名称:networkx,代码行数:7,代码来源:test_cluster.py
示例4: CutOffLessThan5D
def CutOffLessThan5D(self, pairs, dataTbl, cmc):
# build matrix from pairs
sna.loadGraphFromCsv(foMF + ".pairs", " ")
sna.runMeasure("totaldegreeCentrality")
print("\n display results .\n")
sna.displayResults("totaldegreeCentrality")
print("\n")
try:
print("Loading network from file\n(%s)" % (foMF + ".pairs"))
self.graph = networkx.read_edgelist(foMF + ".pairs", delimiter=" ")
self.graph.name = "Social Network"
print("Attempt to draw graph.\n")
G = networkx.cubical_graph()
print("created G")
networkx.draw(G)
plt.show() # display
print("Degree centrality")
d = degree_centrality(G)
for v in G.nodes():
print("%0.2d %5.3f" % (v, d[v]))
except:
print("Unable to open file:", filename)
print("cutoff < 5 degrees end method.\n")
开发者ID:katychuang,项目名称:Python-Social-Network-Analysis,代码行数:31,代码来源:test-networkx.py
示例5: test_cubical
def test_cubical(self):
G = nx.cubical_graph()
assert_equal(nx.triangles(G).values(),
[0, 0, 0, 0, 0, 0, 0, 0])
assert_equal(nx.triangles(G,1),0)
assert_equal(nx.triangles(G,[1,2]).values(),[0, 0])
assert_equal(nx.triangles(G,1),0)
assert_equal(nx.triangles(G,[1,2]),{1: 0, 2: 0})
开发者ID:rafaelpiresm,项目名称:projetos_gae,代码行数:8,代码来源:test_cluster.py
示例6: test_cartesian_product_classic
def test_cartesian_product_classic():
# test some classic product graphs
P2 = nx.path_graph(2)
P3 = nx.path_graph(3)
# cube = 2-path X 2-path
G=cartesian_product(P2,P2)
G=cartesian_product(P2,G)
assert_true(nx.is_isomorphic(G,nx.cubical_graph()))
# 3x3 grid
G=cartesian_product(P3,P3)
assert_true(nx.is_isomorphic(G,nx.grid_2d_graph(3,3)))
开发者ID:Bludge0n,项目名称:AREsoft,代码行数:12,代码来源:test_product.py
示例7: test_is_distance_regular
def test_is_distance_regular(self):
assert_true(nx.is_distance_regular(nx.icosahedral_graph()))
assert_true(nx.is_distance_regular(nx.petersen_graph()))
assert_true(nx.is_distance_regular(nx.cubical_graph()))
assert_true(nx.is_distance_regular(nx.complete_bipartite_graph(3,3)))
assert_true(nx.is_distance_regular(nx.tetrahedral_graph()))
assert_true(nx.is_distance_regular(nx.dodecahedral_graph()))
assert_true(nx.is_distance_regular(nx.pappus_graph()))
assert_true(nx.is_distance_regular(nx.heawood_graph()))
assert_true(nx.is_distance_regular(nx.cycle_graph(3)))
# no distance regular
assert_false(nx.is_distance_regular(nx.path_graph(4)))
开发者ID:argriffing,项目名称:networkx,代码行数:12,代码来源:test_distance_regular.py
示例8: test_tensor_product_classic_result
def test_tensor_product_classic_result():
K2 = nx.complete_graph(2)
G = nx.petersen_graph()
G = tensor_product(G,K2)
assert_true(nx.is_isomorphic(G,nx.desargues_graph()))
G = nx.cycle_graph(5)
G = tensor_product(G,K2)
assert_true(nx.is_isomorphic(G,nx.cycle_graph(10)))
G = nx.tetrahedral_graph()
G = tensor_product(G,K2)
assert_true(nx.is_isomorphic(G,nx.cubical_graph()))
开发者ID:Bludge0n,项目名称:AREsoft,代码行数:13,代码来源:test_product.py
示例9: test_tensor_product
def test_tensor_product():
null=nx.null_graph()
empty1=nx.empty_graph(1)
empty10=nx.empty_graph(10)
K2=nx.complete_graph(2)
K3=nx.complete_graph(3)
K5=nx.complete_graph(5)
K10=nx.complete_graph(10)
P2=nx.path_graph(2)
P3=nx.path_graph(3)
P5=nx.path_graph(5)
P10=nx.path_graph(10)
# null graph
G=tensor_product(null,null)
assert_true(nx.is_isomorphic(G,null))
# null_graph X anything = null_graph and v.v.
G=tensor_product(null,empty10)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(null,K3)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(null,K10)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(null,P3)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(null,P10)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(empty10,null)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(K3,null)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(K10,null)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(P3,null)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(P10,null)
assert_true(nx.is_isomorphic(G,null))
G=tensor_product(P5,K3)
assert_equal(nx.number_of_nodes(G),5*3)
G=tensor_product(K3,K5)
assert_equal(nx.number_of_nodes(G),3*5)
G = nx.petersen_graph()
G = tensor_product(G,K2)
assert_true(nx.is_isomorphic(G,nx.desargues_graph()))
G = nx.cycle_graph(5)
G = tensor_product(G,K2)
assert_true(nx.is_isomorphic(G,nx.cycle_graph(10)))
G = nx.tetrahedral_graph()
G = tensor_product(G,K2)
assert_true(nx.is_isomorphic(G,nx.cubical_graph()))
G = nx.erdos_renyi_graph(10,2/10.)
H = nx.erdos_renyi_graph(10,2/10.)
GH = tensor_product(G,H)
for (u_G,u_H) in GH.nodes_iter():
for (v_G,v_H) in GH.nodes_iter():
if H.has_edge(u_H,v_H) and G.has_edge(u_G,v_G):
assert_true(GH.has_edge((u_G,u_H),(v_G,v_H)))
else:
assert_true(not GH.has_edge((u_G,u_H),(v_G,v_H)))
开发者ID:AhmedPho,项目名称:NetworkX_fork,代码行数:64,代码来源:test_operators.py
示例10:
import matplotlib.pyplot as plt
import networkx as nx
G=nx.cubical_graph()
pos=nx.spring_layout(G) # positions for all nodes
print(G)
# nodes
nx.draw_networkx_nodes(G,pos,
nodelist=[0,1,2,3],
node_color='r',
node_size=500,
alpha=0.8)
nx.draw_networkx_nodes(G,pos,
nodelist=[4,5,6,7],
node_color='b',
node_size=500,
alpha=0.8)
# edges
nx.draw_networkx_edges(G,pos,width=1.0,alpha=0.5)
nx.draw_networkx_edges(G,pos,
edgelist=[(0,1),(1,2),(2,3),(3,0)],
width=8,alpha=0.5,edge_color='r')
nx.draw_networkx_edges(G,pos,
edgelist=[(4,5),(5,6),(6,7),(7,4)],
width=8,alpha=0.5,edge_color='b')
# some math labels
labels={}
开发者ID:aleeds,项目名称:Group-Theory,代码行数:31,代码来源:tmp.py
示例11: test_cartesian_product
def test_cartesian_product():
null=nx.null_graph()
empty1=nx.empty_graph(1)
empty10=nx.empty_graph(10)
K3=nx.complete_graph(3)
K5=nx.complete_graph(5)
K10=nx.complete_graph(10)
P2=nx.path_graph(2)
P3=nx.path_graph(3)
P5=nx.path_graph(5)
P10=nx.path_graph(10)
# null graph
G=cartesian_product(null,null)
assert_true(nx.is_isomorphic(G,null))
# null_graph X anything = null_graph and v.v.
G=cartesian_product(null,empty10)
assert_true(nx.is_isomorphic(G,null))
G=cartesian_product(null,K3)
assert_true(nx.is_isomorphic(G,null))
G=cartesian_product(null,K10)
assert_true(nx.is_isomorphic(G,null))
G=cartesian_product(null,P3)
assert_true(nx.is_isomorphic(G,null))
G=cartesian_product(null,P10)
assert_true(nx.is_isomorphic(G,null))
G=cartesian_product(empty10,null)
assert_true(nx.is_isomorphic(G,null))
G=cartesian_product(K3,null)
assert_true(nx.is_isomorphic(G,null))
G=cartesian_product(K10,null)
assert_true(nx.is_isomorphic(G,null))
G=cartesian_product(P3,null)
assert_true(nx.is_isomorphic(G,null))
G=cartesian_product(P10,null)
assert_true(nx.is_isomorphic(G,null))
# order(GXH)=order(G)*order(H)
G=cartesian_product(P5,K3)
assert_equal(nx.number_of_nodes(G),5*3)
assert_equal(nx.number_of_edges(G),
nx.number_of_edges(P5)*nx.number_of_nodes(K3)+
nx.number_of_edges(K3)*nx.number_of_nodes(P5))
G=cartesian_product(K3,K5)
assert_equal(nx.number_of_nodes(G),3*5)
assert_equal(nx.number_of_edges(G),
nx.number_of_edges(K5)*nx.number_of_nodes(K3)+
nx.number_of_edges(K3)*nx.number_of_nodes(K5))
# test some classic product graphs
# cube = 2-path X 2-path
G=cartesian_product(P2,P2)
G=cartesian_product(P2,G)
assert_true(nx.is_isomorphic(G,nx.cubical_graph()))
# 3x3 grid
G=cartesian_product(P3,P3)
assert_true(nx.is_isomorphic(G,nx.grid_2d_graph(3,3)))
G = nx.erdos_renyi_graph(10,2/10.)
H = nx.erdos_renyi_graph(10,2/10.)
GH = cartesian_product(G,H)
for (u_G,u_H) in GH.nodes_iter():
for (v_G,v_H) in GH.nodes_iter():
if (u_G==v_G and H.has_edge(u_H,v_H)) or \
(u_H==v_H and G.has_edge(u_G,v_G)):
assert_true(GH.has_edge((u_G,u_H),(v_G,v_H)))
else:
assert_true(not GH.has_edge((u_G,u_H),(v_G,v_H)))
开发者ID:AhmedPho,项目名称:NetworkX_fork,代码行数:69,代码来源:test_operators.py
示例12: test_special_cases
def test_special_cases(self):
for n, H in [(0, nx.null_graph()), (1, nx.path_graph(2)),
(2, nx.cycle_graph(4)), (3, nx.cubical_graph())]:
G = nx.hypercube_graph(n)
assert_true(nx.could_be_isomorphic(G, H))
开发者ID:jklaise,项目名称:networkx,代码行数:5,代码来源:test_lattice.py
示例13:
import networkx as nx
import matplotlib.pylab as plt
from plot_multigraph import plot_multigraph
graphs = [
("bull", nx.bull_graph()),
("chvatal", nx.chvatal_graph()),
("cubical", nx.cubical_graph()),
("desargues", nx.desargues_graph()),
("diamond", nx.diamond_graph()),
("dodecahedral", nx.dodecahedral_graph()),
("frucht", nx.frucht_graph()),
("heawood", nx.heawood_graph()),
("house", nx.house_graph()),
("house_x", nx.house_x_graph()),
("icosahedral", nx.icosahedral_graph()),
("krackhardt_kite", nx.krackhardt_kite_graph()),
("moebius_kantor", nx.moebius_kantor_graph()),
("octahedral", nx.octahedral_graph()),
("pappus", nx.pappus_graph()),
("petersen", nx.petersen_graph()),
("sedgewick_maze", nx.sedgewick_maze_graph()),
("tetrahedral", nx.tetrahedral_graph()),
("truncated_cube", nx.truncated_cube_graph()),
("truncated_tetrahedron", nx.truncated_tetrahedron_graph()),
]
plot_multigraph(graphs, 4, 5, node_size=50)
plt.savefig('graphs/small.png')
开发者ID:FangMath,项目名称:networkx-examples,代码行数:29,代码来源:small_graphs.py
示例14: xrange
# -*- coding: utf-8 -*-
import networkx as nx
import matplotlib.pylab as plt
from numpy.random import *
import colorsys
if __name__ == '__main__':
sample = nx.cubical_graph()
for i in xrange(0,50):
sample.add_node(i)
for i in xrange(0,50):
sample.add_edge(i,poisson(lam=30))
#print sample.edges()
try: print nx.shortest_path(sample, 30, 0)
except: print u"ぼっち"
#graph layput
#circular, random, shell, spring, spectral
#ncolors = [colorsys.hsv_to_rgb(h / num_nodes, 1.0, 1.0)for h in range(num_nodes)]
nx.draw(sample, pos=nx.spring_layout(sample), node_color='white',edge_color="g")
plt.savefig("sample.png")
nx.write_gexf(sample, "sample.gexf")
开发者ID:SuzukiTomoyuki,项目名称:program,代码行数:25,代码来源:ex1.py
示例15: generate_cubic
def generate_cubic():
return nx.cubical_graph()
开发者ID:Plutinsky,项目名称:pyUI,代码行数:2,代码来源:graph_operations.py
注:本文中的networkx.cubical_graph函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论