Vue/graf/src/middleware/GrafModel.js
// Contracts an edge, merging its two neighboring nodes
Contracts an edge, merging its two neighboring nodes
Contracts an edge merging its two neighboring nodes
contractEdge(id) {
		let edge = this.id_edge_map.get(id);
		let s_node = edge.getSource();
		let t_node = edge.getTarget();
		let new_node_id = this.curr_node_id;
		this.addNode();
		let target_adj = new Set();
		t_node.getAdjacentOutgoing().forEach(target_adj.add, target_adj);
		s_node.getAdjacentOutgoing().forEach(target_adj.add, target_adj);
		let source_adj = new Set();
		t_node.getAdjacentIncoming().forEach(source_adj.add, source_adj);
		s_node.getAdjacentIncoming().forEach(source_adj.add, source_adj);
		for (let target_node of target_adj) {
			this.addEdgeHelper(new_node_id, target_node.id);
		}
		for (let source_node of source_adj) {
			this.addEdgeHelper(source_node.id, new_node_id);
		}
		this.removeNode(s_node.getId());
		this.removeNode(t_node.getId());
	}
contractEdge ( id ) { let edge = this . id_edge_map . get ( id ) ; let s_node = edge . getSource ( ) ; let t_node = edge . getTarget ( ) ; let new_node_id = this . curr_node_id ; this . addNode ( ) ; let target_adj = new Set ( ) ; t_node . getAdjacentOutgoing ( ) . forEach ( target_adj . add , target_adj ) ; s_node . getAdjacentOutgoing ( ) . forEach ( target_adj . add , target_adj ) ; let source_adj = new Set ( ) ; t_node . getAdjacentIncoming ( ) . forEach ( source_adj . add , source_adj ) ; s_node . getAdjacentIncoming ( ) . forEach ( source_adj . add , source_adj ) ; for ( let target_node of target_adj ) { this . addEdgeHelper ( new_node_id , target_node . id ) ; } for ( let source_node of source_adj ) { this . addEdgeHelper ( source_node . id , new_node_id ) ; } this . removeNode ( s_node . getId ( ) ) ; this . removeNode ( t_node . getId ( ) ) ; }
Contracts an edge, merging its two neighboring nodes
Contracts an edge merging its two neighboring nodes
// This set contains all nodes v connected to s or t such that s or t is the source node connected to v // This set contains all nodes v connected to s or t such that s or t is the target node connected to v