forked from addy1997/python-RRT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.py
More file actions
65 lines (43 loc) · 1.22 KB
/
generator.py
File metadata and controls
65 lines (43 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# coding: utf-8
# In[2]:
from time import time
import networkx as nx
from source.DiGraph import DiGraph
from source.model.Edge import Edge
def text_to_dict(filename):
in_file = open("filename", "r")
lines = in_file.read()
in_file.close()
open_bracket = lines.index("{")
close_bracket = lines.index("}")
graph = eval(lines[open_bracket:close_bracket])
return graph
def specify_vertices(graph):
vertices = []
for node in graph.keys():
vertices.append(node)
return vertices
def specify_edges(graph):
edges = []
for node in graph.key():
edges.append(Edge(node, i))
return edges
def design_graph_object(graph, G= None):
if not G:
G = DiGraph()
for node in graph.keys():
if (node not in G.get_vertices()):
G.add_node(node)
for z in graph[node]:
if (z not in G.get_vertices()):
G.add_node(z)
G.add_edge(node, z)
return G
def set_digraph_library(graph, G):
for nodes in graph.keys():
G.add_node(nodes)
for i in graph[nodes]:
G.add_edge(nodes, i)
return G
# In[ ]: