Attachment 'Crossing-Minimization-ENCODING.txt'
Download 1 %%guess
2 pvalue(L,0) :- width(L,_).
3 pvalue(L,X+1) :- pvalue(L,X), width(L,T), X < T.
4 position( Node, Pos ) | not_position( Node, Pos ) :- in_layer( Layer, Node ), width( Layer, T ), Pos = P + 1,
5 pvalue(Layer,P), P < T.
6
7 %%check
8 %a node must be assigned at most at one position.
9 :- position( Node1, Pos1 ), position( Node1, Pos2 ), Pos1 < Pos2.
10
11 %two nodes of the same layer cannot be assigned at the same position.
12 :- in_layer( Layer1, Node1 ), in_layer( Layer1, Node2 ), position( Node1, Pos1 ), position( Node2, Pos1 ), Node1 != Node2.
13
14 %a node must be assigned at least at one position.
15 node_assigned_at_position( Node ) :- position( Node, Pos ).
16 :- in_layer( Layer1, Node1 ), not node_assigned_at_position( Node1 ).
17
18
19 %%optimization
20 %Computing the edges from same layers.
21 edge_from_same_layers(Node1,Node2,Node3,Node4):- edge(Node1,Node2), edge(Node3,Node4), Node1 < Node3, Node2 != Node4, in_layer(Layer,Node1), in_layer(Layer,Node3).
22
23 %Computing all the crossings.
24 crossing(Node1,Node2,Node3,Node4) :- edge_from_same_layers(Node1,Node2,Node3,Node4), antecedent(Node1,Node3), antecedent(Node4,Node2).
25 crossing(Node1,Node2,Node3,Node4) :- edge_from_same_layers(Node1,Node2,Node3,Node4), antecedent(Node3,Node1), antecedent(Node2,Node4).
26
27 % A node Node1 is an antecedent of a node Node2 if they are in the same layer and the Node1 position is antecedent of the Node2 position.
28 antecedent(Node1,Node2):- in_layer(Layer,Node1), in_layer(Layer,Node2), Node1 != Node2, position(Node1,Pos1), position(Node2,Pos2), Pos1 < Pos2.
29
30 % Assign a penalty to each violation of the crossing.
31 :~ crossing(Node1, Node2, Node3, Node4 ).
Attached Files
You are not allowed to attach a file to this page.