Vue/graf/src/middleware/GrafModel.js
// Contracts a node, connecting its adjacent nodes to each other directly
Contracts a node, connecting its adjacent nodes to each other directly
Contracts a node connecting its adjacent nodes to each other directly
contractNode(id) {
		let node = this.id_node_map.get(id);
		let adj_set = node.getAdjacent();
		let new_node_id = this.curr_node_id;
		this.addNode();
		this.removeNode(id);
		let outgoing_set = new Set();
		let incoming_set = new Set(); 
		for (let adj_node of adj_set) {
			adj_node.getAdjacentOutgoing().forEach(outgoing_set.add, outgoing_set);
			adj_node.getAdjacentIncoming().forEach(incoming_set.add, incoming_set);
		}
		for (let outer_adj_node of outgoing_set) {
			this.addEdgeHelper(new_node_id, outer_adj_node.id);
		}
		for (let outer_adj_node of incoming_set) {
			this.addEdgeHelper(outer_adj_node.id, new_node_id);
		}
		for (let adj_node of adj_set) {
			this.removeNode(adj_node.id);
		}
	}
contractNode ( id ) { let node = this . id_node_map . get ( id ) ; let adj_set = node . getAdjacent ( ) ; let new_node_id = this . curr_node_id ; this . addNode ( ) ; this . removeNode ( id ) ; let outgoing_set = new Set ( ) ; let incoming_set = new Set ( ) ; for ( let adj_node of adj_set ) { adj_node . getAdjacentOutgoing ( ) . forEach ( outgoing_set . add , outgoing_set ) ; adj_node . getAdjacentIncoming ( ) . forEach ( incoming_set . add , incoming_set ) ; } for ( let outer_adj_node of outgoing_set ) { this . addEdgeHelper ( new_node_id , outer_adj_node . id ) ; } for ( let outer_adj_node of incoming_set ) { this . addEdgeHelper ( outer_adj_node . id , new_node_id ) ; } for ( let adj_node of adj_set ) { this . removeNode ( adj_node . id ) ; } }
Contracts a node, connecting its adjacent nodes to each other directly
Contracts a node connecting its adjacent nodes to each other directly
// nodes that will be the targets of new edges // nodes that will be the sources of new edges // add adjacent nodes to the aforementioned sets