Relations between objects are allowed between nodeshot2 objects only
961824
def allow_relation(self, obj1, obj2, **hints):
        
        if obj1._meta.app_label != 'oldimporter' and obj2._meta.app_label != 'oldimporter':
            return True
        return None
746581
def initial(self, request, *args, **kwargs):
        
        super(NodeRelationViewMixin, self).initial(request, *args, **kwargs)
        self.node = get_object_or_404(Node, **{'slug': self.kwargs['slug']})
        self.queryset = self.model.objects.filter(node_id=self.node.id)
1171960
function(state, nodeA, sepHandlerA, nodeB, sepHandlerB) {
	let sepType, nlConstraints, aCons, bCons;

	if (nodeA.nextSibling === nodeB) {
		// sibling separator
		sepType = "sibling";
		aCons = sepHandlerA.after(nodeA, nodeB, state);
		bCons = sepHandlerB.before(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	} else if (nodeB.parentNode === nodeA) {
		// parent-child separator, nodeA parent of nodeB
		sepType = "parent-child";
		aCons = sepHandlerA.firstChild(nodeA, nodeB, state);
		bCons = sepHandlerB.before(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	} else if (nodeA.parentNode === nodeB) {
		// parent-child separator, nodeB parent of nodeA
		sepType = "child-parent";
		aCons = sepHandlerA.after(nodeA, nodeB, state);
		bCons = sepHandlerB.lastChild(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	} else {
		// sibling separator
		sepType = "sibling";
		aCons = sepHandlerA.after(nodeA, nodeB, state);
		bCons = sepHandlerB.before(nodeB, nodeA, state);
		nlConstraints = getSepNlConstraints(state, nodeA, aCons, nodeB, bCons);
	}

	if (nodeA.nodeName === undefined) {
		console.trace();
	}

	if (state.sep.constraints) {
		// Merge the constraints
		state.sep.constraints = mergeConstraints(
			state.env,
			state.sep.constraints,
			nlConstraints
		);
	} else {
		state.sep.constraints = nlConstraints;
	}

	state.env.log('debug/wts/sep', function() {
		return 'constraint' +
			' | ' + sepType +
			' | <' + nodeA.nodeName + ',' + nodeB.nodeName + '>' +
			' | ' + JSON.stringify(state.sep.constraints) +
			' | ' + debugOut(nodeA) +
			' | ' + debugOut(nodeB);
	});

	state.sep.constraints.constraintInfo = {
		onSOL: state.onSOL,
		// force SOL state when separator is built/emitted
		forceSOL: sepHandlerB.forceSOL,
		sepType: sepType,
		nodeA: nodeA,
		nodeB: nodeB,
	};
}
1227642
function addToGlobalNodes(node){
    var nodeToAdd = {
        "_id": node.id(),
        "_world": node.world(),
        "_time": node.time(),
        "_type": (node.nodeTypeName() ? node.nodeTypeName() : "default")
    };

    var containsRel = false;
    // add all the attributes of the node to the JSON
    graph.resolver().resolveState(node, false).each(function (attributeKey, elemType, elem) {
        var key = graph.resolver().hashToString(attributeKey);

        if(elemType == org.mwg.Type.BOOL || elemType == org.mwg.Type.STRING || elemType == org.mwg.Type.INT
            || elemType == org.mwg.Type.LONG || elemType == org.mwg.Type.DOUBLE) { //primitive types
            nodeToAdd[key] = elem;
        } else if(elemType == org.mwg.Type.RELATION) { //classic relation
            nodeToAdd[key] = [];
            for (var i = 0; i < elem.size(); ++i){
                nodeToAdd[key].push(elem.get(i));
            }
            containsRel = true;
        } else if(elemType == org.mwg.Type.LONG_TO_LONG_ARRAY_MAP) { //indexed relation
            nodeToAdd[key] = [];
            elem.each(function(relKey,relIdNode) {
                nodeToAdd[key].push(relIdNode);
            });
            containsRel = true;
        } else {
            throw "Type(" + elemType + ") is not yet managed. Please update the debugger."
        }
    });
    // if the node contains a relationship, we add them into a global variable to deal with the relationships later
    if (containsRel){
        gNodesWithRel.push(nodeToAdd);
    }

    // we sort the nodes per type
    if (gNodesPerType[nodeToAdd._type] == null){
        gNodesPerType[nodeToAdd._type] = [];
        colorsByNodeType[nodeToAdd._type] = getRandomColor(); // add the type of the node to the type list and assign a color to the type
    }
    gNodesPerType[nodeToAdd._type].push(nodeToAdd);

    // finally we add them to the global array containing all the nodes
    gAllNodes.push(nodeToAdd);

}
1205371
def connect(self, node, properties=None):
        
        self._check_node(node)

        if not self.definition['model'] and properties:
            raise NotImplementedError(
                "Relationship properties without using a relationship model "
                "is no longer supported."
            )

        params = {}
        rel_model = self.definition['model']
        rp = None  # rel_properties

        if rel_model:
            rp = {}
            # need to generate defaults etc to create fake instance
            tmp = rel_model(**properties) if properties else rel_model()
            # build params and place holders to pass to rel_helper
            for p, v in rel_model.deflate(tmp.__properties__).items():
                rp[p] = '{' + p + '}'
                params[p] = v

            if hasattr(tmp, 'pre_save'):
                tmp.pre_save()

        new_rel = _rel_helper(lhs='us', rhs='them', ident='r', relation_properties=rp, **self.definition)
        q = "MATCH (them), (us) WHERE id(them)={them} and id(us)={self} " \
            "CREATE UNIQUE" + new_rel

        params['them'] = node.id

        if not rel_model:
            self.source.cypher(q, params)
            return True

        rel_ = self.source.cypher(q + " RETURN r", params)[0][0][0]
        rel_instance = self._set_start_end_cls(rel_model.inflate(rel_), node)

        if hasattr(rel_instance, 'post_save'):
            rel_instance.post_save()

        return rel_instance
289037
def get_related_node(self, node, relation):
        """"""
        G = self.G
        for edge in G.edges(node):
            to = edge[1]

            to_relation = G.edges[node, to]['relation']
            if to_relation == relation:
                return to
        return None
20998
def handle_unqualified_relation(self, _, __, tokens: ParseResults) -> ParseResults:
        """"""
        subject_node_dsl = self.ensure_node(tokens[SUBJECT])
        object_node_dsl = self.ensure_node(tokens[OBJECT])
        relation = tokens[RELATION]
        self.graph.add_unqualified_edge(subject_node_dsl, object_node_dsl, relation)
        return tokens
553471
function linkTrees(minNodeTree, other) {
  other.parent = minNodeTree;
  other.sibling = minNodeTree.child;
  minNodeTree.child = other;
  minNodeTree.degree++;
}
342024
void build(int nodeOffset, GraphMeshData graphData, List<int[]> connections) {
		for (int n = 0; n < connections.size(); n++) {
			int[] nodeConnections = connections.get(n);
			MeshData tile = graphData.getTile(n);
			Poly node = graphData.getNode(n);
			for (int connection : nodeConnections) {
				MeshData neighbourTile = graphData.getTile(connection - nodeOffset);
				if (neighbourTile != tile) {
					buildExternalLink(tile, node, neighbourTile);
				} else {
					Poly neighbour = graphData.getNode(connection - nodeOffset);
					buildInternalLink(tile, node, neighbourTile, neighbour);
				}
			}
		}
	}
72126
function ( relationships ) {

			var model;
			var lightAttribute;

			relationships.children.forEach( function ( child ) {

				var attr = fbxTree.Objects.NodeAttribute[ child.ID ];

				if ( attr !== undefined ) {

					lightAttribute = attr;

				}

			} );

			if ( lightAttribute === undefined ) {

				model = new THREE.Object3D();

			} else {

				var type;

				// LightType can be undefined for Point lights
				if ( lightAttribute.LightType === undefined ) {

					type = 0;

				} else {

					type = lightAttribute.LightType.value;

				}

				var color = 0xffffff;

				if ( lightAttribute.Color !== undefined ) {

					color = new THREE.Color().fromArray( lightAttribute.Color.value );

				}

				var intensity = ( lightAttribute.Intensity === undefined ) ? 1 : lightAttribute.Intensity.value / 100;

				// light disabled
				if ( lightAttribute.CastLightOnObject !== undefined && lightAttribute.CastLightOnObject.value === 0 ) {

					intensity = 0;

				}

				var distance = 0;
				if ( lightAttribute.FarAttenuationEnd !== undefined ) {

					if ( lightAttribute.EnableFarAttenuation !== undefined && lightAttribute.EnableFarAttenuation.value === 0 ) {

						distance = 0;

					} else {

						distance = lightAttribute.FarAttenuationEnd.value;

					}

				}

				// TODO: could this be calculated linearly from FarAttenuationStart to FarAttenuationEnd?
				var decay = 1;

				switch ( type ) {

					case 0: // Point
						model = new THREE.PointLight( color, intensity, distance, decay );
						break;

					case 1: // Directional
						model = new THREE.DirectionalLight( color, intensity );
						break;

					case 2: // Spot
						var angle = Math.PI / 3;

						if ( lightAttribute.InnerAngle !== undefined ) {

							angle = THREE.Math.degToRad( lightAttribute.InnerAngle.value );

						}

						var penumbra = 0;
						if ( lightAttribute.OuterAngle !== undefined ) {

						// TODO: this is not correct - FBX calculates outer and inner angle in degrees
						// with OuterAngle > InnerAngle && OuterAngle <= Math.PI
						// while three.js uses a penumbra between (0, 1) to attenuate the inner angle
							penumbra = THREE.Math.degToRad( lightAttribute.OuterAngle.value );
							penumbra = Math.max( penumbra, 1 );

						}

						model = new THREE.SpotLight( color, intensity, distance, angle, penumbra, decay );
						break;

					default:
						console.warn( 'THREE.FBXLoader: Unknown light type ' + lightAttribute.LightType.value + ', defaulting to a THREE.PointLight.' );
						model = new THREE.PointLight( color, intensity );
						break;

				}

				if ( lightAttribute.CastShadows !== undefined && lightAttribute.CastShadows.value === 1 ) {

					model.castShadow = true;

				}

			}

			return model;

		}
478827
@Override
    protected void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> rlHolders)
    {
        if (log.isDebugEnabled())
            log.debug("Persisting " + entity);

        // All Modifying Neo4J operations must be executed within a transaction
        checkActiveTransaction();

        GraphDatabaseService graphDb = getConnection();

        try
        {

            // Top level node
            Node node = mapper.getNodeFromEntity(entity, id, graphDb, entityMetadata, isUpdate);

            if (node != null)
            {
                MetamodelImpl metamodel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                        getPersistenceUnit());

                ((Neo4JTransaction) resource).addProcessedNode(id, node);

                if (!rlHolders.isEmpty())
                {
                    for (RelationHolder rh : rlHolders)
                    {
                        // Search Node (to be connected to ) in Neo4J graph
                        EntityMetadata targetNodeMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                                rh.getRelationValue().getClass());
                        Object targetNodeKey = PropertyAccessorHelper.getId(rh.getRelationValue(), targetNodeMetadata);
                        // Node targetNode = mapper.searchNode(targetNodeKey,
                        // targetNodeMetadata, graphDb);

                        Node targetNode = null; // Target node connected through
                                                // relationship

                        /**
                         * If Relationship is with an entity in Neo4J, Target
                         * node must already have been created Get a handle of
                         * it from processed nodes and add edges to it. Else, if
                         * relationship is with an entity in a database other
                         * than Neo4J, create a "Proxy Node" that points to a
                         * row in other database. This proxy node contains key
                         * equal to primary key of row in other database.
                         * */

                        if (isEntityForNeo4J(targetNodeMetadata))
                        {
                            targetNode = ((Neo4JTransaction) resource).getProcessedNode(targetNodeKey);
                        }
                        else
                        {
                            // Create Proxy nodes for insert requests
                            if (!isUpdate)
                            {
                                targetNode = mapper.createProxyNode(id, targetNodeKey, graphDb, entityMetadata,
                                        targetNodeMetadata);
                            }
                        }

                        if (targetNode != null)
                        {
                            // Join this node (source node) to target node via
                            // relationship
                            DynamicRelationshipType relType = DynamicRelationshipType.withName(rh.getRelationName());
                            Relationship relationship = node.createRelationshipTo(targetNode, relType);

                            // Populate relationship's own properties into it
                            Object relationshipObj = rh.getRelationVia();
                            if (relationshipObj != null)
                            {
                                mapper.populateRelationshipProperties(entityMetadata, targetNodeMetadata, relationship,
                                        relationshipObj);

                                // After relationship creation, manually index
                                // it if desired
                                EntityMetadata relationMetadata = KunderaMetadataManager.getEntityMetadata(
                                        kunderaMetadata, relationshipObj.getClass());
                                if (!isUpdate)
                                {
                                    indexer.indexRelationship(relationMetadata, graphDb, relationship, metamodel);
                                }
                                else
                                {
                                    indexer.updateRelationshipIndex(relationMetadata, graphDb, relationship, metamodel);
                                }

                            }
                        }

                    }
                }

                // After node creation, manually index this node, if desired
                if (!isUpdate)
                {
                    indexer.indexNode(entityMetadata, graphDb, node, metamodel);
                }
                else
                {
                    indexer.updateNodeIndex(entityMetadata, graphDb, node, metamodel);
                }
            }

        }
        catch (Exception e)
        {
            log.error("Error while persisting entity " + entity + ", Caused by: ", e);
            throw new PersistenceException(e);
        }
    }
957605
function(obj, type){
		if(!this.enabled){ return;}
		var relation = this.relation[type];
		if(!relation){ return;}

		this.modifyNodes = [];

		switch(relation){
			case 'node':      this.setEdgeByNodeObj(obj); break;
			case 'link':      this.setEdgeByLinkObj(obj); break;
			case 'separator': this.setEdgeBySeparator(obj); break;
			default:          this.modifyOtherInfo(obj,relation); break;
		}

		if(this.modifyNodes.length>0){ this.remakeComponent();}
	}
373103
public Difference<BaseType> compareObjects(List<String> field1,
                                               ObjectType node1,
                                               List<String> field2,
                                               ObjectType node2)
            throws InvalidArrayIdentity, DuplicateArrayIdentity {
        Difference<BaseType> ret = new Difference<>();
        // Field by field comparison of obj1 to obj2. 
        for (Iterator<Map.Entry<String, BaseType>> fields = getFields(node1); fields.hasNext();) {
            Map.Entry<String, BaseType> field = fields.next();
            String fieldName = field.getKey();
            field1.add(fieldName);
            BaseType value1 = field.getValue();

            if (hasField(node2, fieldName)) {
                // If both obj1 and obj2 have the same field, compare recursively
                field2.add(fieldName);
                BaseType value2 = getField(node2, fieldName);
                ret.add(compareNodes(field1, value1, field2, value2));
                pop(field2);
            } else {
                // obj1.field1 exists, obj2.field1 does not, so it is removed
                ret.add(new Removal(field1, value1));
            }
            pop(field1);
        }
        // Now compare any new nodes added to obj2
        for (Iterator<Map.Entry<String, BaseType>> fields = getFields(node2); fields.hasNext();) {
            Map.Entry<String, BaseType> field = fields.next();
            String fieldName = field.getKey();
            if (!hasField(node1, fieldName)) {
                field2.add(fieldName);
                ret.add(new Addition(field2, field.getValue()));
                pop(field2);
            }
        }
        return ret;
    }
706618
def relations_of(self, target, include_object=False):
        '''  '''
        if include_object:
            _ = self._execute('''
                select relations.name, ob2.code from relations, objects as ob1, objects as ob2 where relations.src=ob1.id and ob2.id=relations.dst and ob1.code=?
            ''', (self.serialize(target),))
            for i in _:
                yield i[0], self.deserialize(i[1])
        else:

            _ = self._execute('''
                select distinct relations.name from relations, objects where relations.src=objects.id and objects.code=?
            ''', (self.serialize(target),))
            for i in _:
                yield i[0]
352698
def getLinkInterfaces(self, node1, node2):
        '''
        
        '''
        linkdata = self.getLink(node1,node2)
        return linkdata[node1],linkdata[node1]
564649
function _resp2json(doc){
	console.log("_resp2json: " + doc);

	var kids = []; // ret

	// Extract the intersting graphs.
	var topo_graph_field = 'topology_graph_json';
	var trans_graph_field = 'regulates_transitivity_graph_json';
	var topo_graph = new model.graph();
	topo_graph.load_base_json(JSON.parse(doc[topo_graph_field]));
	var trans_graph = new model.graph();
	trans_graph.load_base_json(JSON.parse(doc[trans_graph_field]));

	//console.log('topo: ' + doc[topo_graph_field]);

	// Collect child ids.
	var child_ids = [];
	us.each(topo_graph.get_child_nodes(doc['id']), function(kid){
	    child_ids.push(kid.id());
	});

	// Using the badger, get the spans for the IDs.
	var ac_badges = new CountBadges(filter_manager);
	var ids_to_badge_text = ac_badges.get_future_badges(child_ids);

	//
	us.each(topo_graph.get_child_nodes(doc['id']), function(kid){

	    // Extract some info.
	    var oid = doc['id'];
	    var sid = kid.id();
	    var preds = topo_graph.get_predicates(sid, oid);
	    var imgsrc = bbop.resourcify(sd.image_base, preds[0], 'gif');

	    var lbl_txt =  kid.label() || sid;
	    
	    // Push template.
	    kids.push({
		'id': sid,
		'text': lbl_txt + ids_to_badge_text[sid],
		'icon': imgsrc,
		'state': {
		    'opened': false,
		    'disabled': false,
		    'selected': false
		},
		'children': true, // unknowable w/o lookahead
		'li_attr': {},
		'a_attr': {}
	    });
	});

	return kids;
    }
564624
public static void setNestedSerializersSnapshots(
		CompositeTypeSerializerSnapshot<?, ?> compositeSnapshot,
		TypeSerializerSnapshot<?>... nestedSnapshots) {

		NestedSerializersSnapshotDelegate delegate = new NestedSerializersSnapshotDelegate(nestedSnapshots);
		compositeSnapshot.setNestedSerializersSnapshotDelegate(delegate);
	}