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/TopologyManager.java b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
index bf3874b..67e8e5d 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyManager.java
@@ -951,10 +951,7 @@
         assert (link == srcPort.getOutgoingLink());
         if (link == null) {
             link = new LinkImpl(networkGraph, srcPort, dstPort);
-            PortImpl srcPortImpl = getPortImpl(srcPort);
-            PortImpl dstPortImpl = getPortImpl(dstPort);
-            srcPortImpl.setOutgoingLink(link);
-            dstPortImpl.setIncomingLink(link);
+            networkGraph.putLink(link);
 
             // Remove all Devices attached to the Ports
             ArrayList<DeviceEvent> devicesToRemove = new ArrayList<>();
@@ -1019,8 +1016,11 @@
         if (link == null) {
             log.warn("Link {} already removed on src Port", linkEvent);
         }
-        getPortImpl(dstPort).setIncomingLink(null);
-        getPortImpl(srcPort).setOutgoingLink(null);
+
+        // TODO should we check that we get the same link from each port?
+        if (link != null) {
+            networkGraph.removeLink(link);
+        }
 
         apiRemovedLinkEvents.add(linkEvent);
     }