edges updated following the new schema

parent ac239825
...@@ -85,11 +85,16 @@ def createObjectResourcesAndCoreObjects(): ...@@ -85,11 +85,16 @@ def createObjectResourcesAndCoreObjects():
list of object with ID = id list of object with ID = id
XXX slow implementation XXX slow implementation
''' '''
def getSuccessorList(node_id, predicate=lambda source, destination, edge_data: True): def getSuccessorList(node_id, predicate=lambda source, destination, edge_class, edge_data: True):
successor_list = [] # dummy variable that holds the list to be returned successor_list = [] # dummy variable that holds the list to be returned
for source, destination, edge_data in edges.values(): # for all the values in the dictionary edges
for edge in edges.values():
source = edge["source"]
destination = edge["destination"]
edge_class = edge["_class"]
edge_data = edge.get("data", {})
if source == node_id: # for the node_id argument if source == node_id: # for the node_id argument
if predicate(source, destination, edge_data): # find its 'destinations' and if predicate(source, destination, edge_class, edge_data): # find its 'destinations' and
successor_list.append(destination) # append it to the successor list successor_list.append(destination) # append it to the successor list
# XXX We should probably not need to sort, but there is a bug that # XXX We should probably not need to sort, but there is a bug that
# prevents Topology10 to work if this sort is not used. # prevents Topology10 to work if this sort is not used.
...@@ -215,9 +220,9 @@ def createObjectResourcesAndCoreObjects(): ...@@ -215,9 +220,9 @@ def createObjectResourcesAndCoreObjects():
coreObject.nextIds=getSuccessorList(element['id']) coreObject.nextIds=getSuccessorList(element['id'])
# (Below is only for Dismantle for now) # (Below is only for Dismantle for now)
# get the successorList for the 'Parts' # get the successorList for the 'Parts'
coreObject.nextPartIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Part') coreObject.nextPartIds=getSuccessorList(element['id'], lambda source, destination, edge_class, edge_data: edge_data.get('entity',{}) == 'Part')
# get the successorList for the 'Frames' # get the successorList for the 'Frames'
coreObject.nextFrameIds=getSuccessorList(element['id'], lambda source, destination, edge_data: edge_data.get('entity') == 'Frame') coreObject.nextFrameIds=getSuccessorList(element['id'], lambda source, destination, edge_class, edge_data: edge_data.get('entity',{}) == 'Frame')
# loop through all the core objects # loop through all the core objects
# to read predecessors # to read predecessors
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment