buildgraph: new internal data handling, new serialization
This commit is contained in:
parent
1f1b28dc99
commit
06ad6a6e31
6 changed files with 159 additions and 91 deletions
|
@ -2,14 +2,10 @@ import numpy as np
|
|||
|
||||
|
||||
class GraphConnection():
|
||||
def __init__(self, graph, from_point, to_point, distance=None):
|
||||
self.graph = graph
|
||||
def __init__(self, from_point, to_point, distance=None):
|
||||
self.from_point = from_point
|
||||
self.to_point = to_point
|
||||
self.distance = distance if distance is not None else abs(np.linalg.norm(from_point.xy - to_point.xy))
|
||||
|
||||
if to_point in from_point.connections:
|
||||
self.graph.connections.remove(from_point.connections[to_point])
|
||||
|
||||
from_point.connections[to_point] = self
|
||||
to_point.connections_in[from_point] = self
|
||||
def serialize(self):
|
||||
return (self.distance, )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue