Skip to content

HighwayGraph.matching_edges #179

Description

@yakra

Similar changes yielded a 37.7% speed improvement Creating regional data graphs in the C++ version:

self.unique_waypoints=dict()
all_waypoint_list=all_waypoints.point_list()
self.highway_systems=highway_systems

Add:

self.edges=set()
self.collapsed_edges=set()

ifnotduplicate:
graph.vertices[s.waypoint1.unique_name].incident_edges.append(self)
graph.vertices[s.waypoint2.unique_name].incident_edges.append(self)

Add graph.edges.add(self) here.


ifnotduplicate:
self.vertex1.incident_collapsed_edges.append(self)
self.vertex2.incident_collapsed_edges.append(self)

Add graph.collapsed_edges.add(self) here.


edge1=vertex_info.incident_collapsed_edges[0]
edge2=vertex_info.incident_collapsed_edges[1]

Add graph.collapsed_edges.add(self) here.


ifremoved!=1:
print("ERROR: edge1 "+str(edge1) +" removed from "+str(removed) +" adjacency lists instead of 1.")

Add graph.collapsed_edges.remove(edge1) here.
ifremoved!=1:
print("ERROR: edge2 "+str(edge2) +" removed from "+str(removed) +" adjacency lists instead of 1.")

Add graph.collapsed_edges.remove(edge2) here.


defmatching_edges(self, regions=None, systems=None, placeradius=None):
# return a set of edges from the graph, optionally
# restricted by region or system or placeradius area
edge_set=set()
forvinself.vertices.values():
foreinv.incident_edges:

Lose the first for loop, and change the second to for e in self.edges:.


defmatching_collapsed_edges(self, regions=None, systems=None,
placeradius=None):
# return a set of edges from the graph edges for the collapsed
# edge format, optionally restricted by region or system or
# placeradius area
edge_set=set()
forvinself.vertices.values():
ifv.is_hidden:
continue
foreinv.incident_collapsed_edges:

Lose the first for loop, and the if v.is_hidden: check.
Change the second loop to for e in self.collapsed_edges:.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions