def __init__(self, source, target, graph, edgeType="", basicAttrs=None): """ Create a new edge instance. Usually this constructor shall not be used directly @param source A node instance @param target The node instance that acts as the target node @param graph The graph this edge belongs to @param The edge type @param basicAttrs The basic attributes, or None to use empty set. """ #Ensure we have valid ID strings if isinstance(source, str): Identifier.checkIdentifier(source) elif isinstance(source, Node): target = source.id if isinstance(target, str): Identifier.checkIdentifier(target) elif isinstance(source, Node): source = target.id self.source = source self.target = target self.graph = graph self.type = edgeType #Serialize the edge database keys self.activeKey = "%s\x1F%s\x0E%s" % (edgeType, self.source, self.target) self.passiveKey = "%s\x1F%s\x0F%s" % (edgeType, self.target, self.source) #Initialize basic and extended attributes self.initializeAttributes(basicAttrs)