当前位置: 首页>>代码示例>>Python>>正文


Python Graph.printEdges方法代码示例

本文整理汇总了Python中Graph.Graph.printEdges方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.printEdges方法的具体用法?Python Graph.printEdges怎么用?Python Graph.printEdges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph.Graph的用法示例。


在下文中一共展示了Graph.printEdges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: str

# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import printEdges [as 别名]
	print '   + Mashing completed!';
	print "[!] Enter time point 3 - Enter add node/edge:" + str(time.time() - start_time);
	g.AddNodes(tup[0],collog); 	# A connection to log
	g.AddEdges(tup[1],collog);	# A connection to log
	print "[!] Enter time point 4 - Finish add node/edge:" + str(time.time() - start_time);
	print '   + ' + str(len(tup[0])) + ' nodes and ' + str(len(tup[1])) + ' edges added.';
	#	sys.stdout.write();
	print ' - Start prettify the graph...';
	print "[!] Enter time point 5 - Enter Prunning:" + str(time.time() - start_time);
	if (count>STARTING_PRUNNING_PREVENTION_BIAS):  # a bias to avoid "early birds" to be removed
		GraphPrunning(g,collog);
		print '   + Well, it is beautiful now!';
	else:
		print '   + Prunning skipped! Due to staring bias...';
	current_time = current_time + DELTA_TIME;
	print 'Finished corpus number ' + str(count) + ';)';
	print "[!] Enter time point 6 - Finished Prunning:" + str(time.time() - start_time);
	if (count == MAXIMUM_NUMBER_OF_CORPUS): break;
	
	g.printNodes();
	g.printEdges();
	print "[!] Enter time point 7 - End corpus:" + str(time.time() - start_time);
	## Record to result log collection
	colresultlog.insert_one({'timestamp': datetime.now(), 'nodes' : json.dumps(g.GetNodesSTRwithFreq()), 'edges' : json.dumps(g.GetEdgeSTRwithFreq())});
	print "\n\n";
	#sys.stdout.write("\n\n" + '\n');
	#sys.stdout.flush()

print "\n Final result: ";
g.printNodes();
g.printEdges();
开发者ID:nduy,项目名称:graphbased-headlines-topic-track,代码行数:33,代码来源:main.py

示例2: Graph

# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import printEdges [as 别名]
    [6, 5], [6, 7],
    [7, 4], [7, 5], [7, 6], [7, 8],
    [8, 4], [8, 7], [8, 9], [8, 10], [8, 11],
    [9, 8], [9, 11],
    [10, 2], [10, 4], [10, 8], [10, 11],
    [11, 8], [11, 9], [11, 10]
  ]

graph1 = Graph(vertices, edges)
print("The vertices in graph1: " + str(graph1.getVertices()))
print("The number of vertices in graph1: " + str(graph1.getSize()))
print("The vertex with index 1 is " + graph1.getVertex(1))
print("The index for Miami is " + str(graph1.getIndex("Miami")))
print("The degree for Miami is " + str(graph1.getDegree("Miami")))
print("The edges for graph1:")
graph1.printEdges()
    
graph1.addVertex("Savannah")
graph1.addEdge("Atlanta", "Savannah")
graph1.addEdge("Savannah", "Atlanta")
print("\nThe edges for graph1 after adding a new vertex and edges:")
graph1.printEdges()

# List of Edge objects for graph in Figure 16.3(a)
names = ["Peter", "Jane", "Mark", "Cindy", "Wendy"]
edges = [[0, 2], [1, 2], [2, 4], [3, 4]]

# Create a graph with 5 vertices
graph2 = Graph(names, edges)
print("\nThe number of vertices in graph2: " 
      + str(graph2.getSize()))
开发者ID:EthanSeaver,项目名称:Python-Projects,代码行数:33,代码来源:TestGraph.py

示例3: eval

# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import printEdges [as 别名]
l = eval(l[0])
v = []
for i in range(l):
    v.append(fin.readline().split(" "))

for row in range(len(v)):
    for column in range(len(v[row])):
        v[row][column] = eval(v[row][column])
counter = 0
vertex = []
for i in range(len(v)):
    vertex.append(str(v[i][0]))
edges = []
for i in range(l):
    for j in range(1, len(v[i])):
        edges.append([])
        edges[counter].append(i)
        edges[counter].append(v[i][j])
        counter += 1

g = Graph(vertex, edges)
tree = g.dfs(0)
print("The number of vertricies is: " + str(l))
g.printEdges()
if tree.getNumberOfVerticesFound() == l:
    print("They are connected")
else:
    print("They are not connected")


开发者ID:dmaslin,项目名称:Python-work,代码行数:30,代码来源:22.1.py


注:本文中的Graph.Graph.printEdges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。