Break the references between Port and Link.

This is in preparation for implementing topology versioning. Ports may have
different Links in different versions of the topology, so we don't want the
reference inside the Port object. References are now held in indexes in the
NetworkGraphImpl.

As a result of this, there was a small API change:
  NetworkGraph.getLink  ->  NetworkGraph.getOutgoingLink
  NetworkGraph.getIncomingLink was added.

Change-Id: I086d198c8040607253c8729b9d5f94ab6bc738db
diff --git a/src/main/java/net/onrc/onos/core/topology/LinkImpl.java b/src/main/java/net/onrc/onos/core/topology/LinkImpl.java
index 4333e38..bf66100 100644
--- a/src/main/java/net/onrc/onos/core/topology/LinkImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/LinkImpl.java
@@ -1,5 +1,7 @@
 package net.onrc.onos.core.topology;
 
+import net.onrc.onos.core.util.SwitchPort;
+
 /**
  * Link Object stored in In-memory Topology.
  * <p/>
@@ -7,8 +9,8 @@
  * but this Object itself will not issue any read/write to the DataStore.
  */
 public class LinkImpl extends NetworkGraphObject implements Link {
-    protected Port srcPort;
-    protected Port dstPort;
+    private SwitchPort srcPort;
+    private SwitchPort dstPort;
 
     protected static final Double DEFAULT_CAPACITY = Double.POSITIVE_INFINITY;
     protected Double capacity = DEFAULT_CAPACITY;
@@ -26,39 +28,28 @@
      */
     public LinkImpl(NetworkGraph graph, Port srcPort, Port dstPort) {
         super(graph);
-        this.srcPort = srcPort;
-        this.dstPort = dstPort;
-        setToPorts();
+        this.srcPort = srcPort.asSwitchPort();
+        this.dstPort = dstPort.asSwitchPort();
     }
 
     @Override
     public Switch getSrcSwitch() {
-        return srcPort.getSwitch();
+        return graph.getSwitch(srcPort.dpid().value());
     }
 
     @Override
     public Port getSrcPort() {
-        return srcPort;
+        return graph.getPort(srcPort.dpid().value(), (long) srcPort.port().value());
     }
 
     @Override
     public Switch getDstSwitch() {
-        return dstPort.getSwitch();
+        return graph.getSwitch(dstPort.dpid().value());
     }
 
     @Override
     public Port getDstPort() {
-        return dstPort;
-    }
-
-    protected void setToPorts() {
-        ((PortImpl) srcPort).setOutgoingLink(this);
-        ((PortImpl) dstPort).setIncomingLink(this);
-    }
-
-    protected void unsetFromPorts() {
-        ((PortImpl) srcPort).setOutgoingLink(null);
-        ((PortImpl) dstPort).setIncomingLink(null);
+        return graph.getPort(dstPort.dpid().value(), (long) dstPort.port().value());
     }
 
     @Override