NodeInfo GetOrCreateNodeInfo(int node) {
     NodeInfo nodeInfo;
     if (!nodeInfoDictionary.TryGetValue(node, out nodeInfo)) {
         nodeInfo = new NodeInfo();
         nodeInfoDictionary[node] = nodeInfo;
     }
     return nodeInfo;
 }
         void DisconnectNodeFromGraph(int u, NodeInfo uNodeInfo) {
            foreach (int v in uNodeInfo.OutEdges)
                nodeInfoDictionary[v].RemoveInEdge(u);

            foreach (int v in uNodeInfo.OutConstrainedEdges)
                nodeInfoDictionary[v].RemoveInConstrainedEdge(u);

            foreach (int v in uNodeInfo.InEdges)
                nodeInfoDictionary[v].RemoveOutEdge(u);

            foreach (int v in uNodeInfo.InConstrainedEdges)
                nodeInfoDictionary[v].RemoveOutConstrainedEdge(u);

            nodeInfoDictionary.Remove(u);
        }
  void AddNodeToBucketsSourcesAndSinks(int v, NodeInfo nodeInfo) {
     if (nodeInfo.InDegree == 0)
         sources.Insert(v);
     else if (nodeInfo.OutDegree == 0)
         sinks.Insert(v);
     else if (nodeInfo.InDegreeOfConstrainedEdges == 0)
         GetOrCreateBucket(nodeInfo.DeltaDegree).Insert(v);
 }