Fix anchor behavior in relations

Change-Id: Ia9e7b047a371e0bf1be91961d304c26ded44268f
diff --git a/dev/js/src/match/relations.js b/dev/js/src/match/relations.js
index 1451c1e..942acee 100644
--- a/dev/js/src/match/relations.js
+++ b/dev/js/src/match/relations.js
@@ -69,15 +69,16 @@
         if (target != undefined) {
 
           // Check if the source is a span anchor
+          /*
           var start = edge.srcStart;
           if (start !== edge.srcEnd) {
             start = [start, edge.srcEnd];
           };
-
+          */
           
           // Add relation
           var relation = {
-            start : start,
+            start : [edge.srcStart, edge.srcEnd],
             end : target,
             direction : 'uni',
             label : edge.label
@@ -421,58 +422,74 @@
 
         // Check for long anchors
         if (v.start instanceof Array) {
-          var middle = Math.ceil(Math.abs(v.start[1] - v.start[0]) / 2) + v.start[0];
 
-          // Calculate signature to avoid multiple anchors
-          var anchorSig = "#" + v.start[0] + "_" + v.start[1];
-          if (v.start[0] > v.start[1]) {
-            anchorSig = "#" + v.start[1] + "_" + v.start[0];
-          };
+          if (v.start[0] == v.start[1]) {
+            v.start = v.start[0];
+          }
 
-          // Check if the anchor already exist
-          var anchor = anchors[anchorSig];
-          if (anchor === undefined) {
-            anchor = {
-              "first":   v.start[0],
-              "last" :   v.start[1],
-              "length" : v.start[1] - v.start[0]
+          else {
+          
+            var middle = Math.ceil(Math.abs(v.start[1] - v.start[0]) / 2) + v.start[0];
+
+            // Calculate signature to avoid multiple anchors
+            var anchorSig = "#" + v.start[0] + "_" + v.start[1];
+            if (v.start[0] > v.start[1]) {
+              anchorSig = "#" + v.start[1] + "_" + v.start[0];
             };
-            anchors[anchorSig] = anchor;
-            // anchors.push(v.startAnchor);
+            
+            // Check if the anchor already exist
+            var anchor = anchors[anchorSig];
+            if (anchor === undefined) {
+              anchor = {
+                "first":   v.start[0],
+                "last" :   v.start[1],
+                "length" : v.start[1] - v.start[0]
+              };
+              anchors[anchorSig] = anchor;
+              // anchors.push(v.startAnchor);
+            };
+
+            v.startAnchor = anchor;
+
+            // Add to anchors list
+            v.start = middle;
           };
-
-          v.startAnchor = anchor;
-
-          // Add to anchors list
-          v.start = middle;
         };
 
         if (v.end instanceof Array) {
-          var middle = Math.abs(v.end[0] - v.end[1]) + v.end[0];
 
-          // Calculate signature to avoid multiple anchors
-          var anchorSig = "#" + v.end[0] + "_" + v.end[1];
-          if (v.end[0] > v.end[1]) {
-            anchorSig = "#" + v.end[1] + "_" + v.end[0];
-          };
+          if (v.end[0] == v.end[1]) {
+            v.end = v.end[0];
+          }
 
-          // Check if the anchor already exist
-          var anchor = anchors[anchorSig];
-          if (anchor === undefined) {
-            anchor = {
-              "first":   v.end[0],
-              "last" :   v.end[1],
-              "length" : v.end[1] - v.end[0]
+          else {
+
+            var middle = Math.abs(v.end[0] - v.end[1]) + v.end[0];
+
+            // Calculate signature to avoid multiple anchors
+            var anchorSig = "#" + v.end[0] + "_" + v.end[1];
+            if (v.end[0] > v.end[1]) {
+              anchorSig = "#" + v.end[1] + "_" + v.end[0];
             };
-            anchors[anchorSig] = anchor;
-            // anchors.push(v.startAnchor);
+
+            // Check if the anchor already exist
+            var anchor = anchors[anchorSig];
+            if (anchor === undefined) {
+              anchor = {
+                "first":   v.end[0],
+                "last" :   v.end[1],
+                "length" : v.end[1] - v.end[0]
+              };
+              anchors[anchorSig] = anchor;
+              // anchors.push(v.startAnchor);
+            };
+            
+            v.endAnchor = anchor;
+
+            // Add to anchors list
+            // anchors.push(v.endAnchor);
+            v.end = middle;
           };
-
-          v.endAnchor = anchor;
-
-          // Add to anchors list
-          // anchors.push(v.endAnchor);
-          v.end = middle;
         };
 
         v.first = v.start;