Beispiel #1
0
        public void RemoveAtHead()
        {
            if (Head == null)
                return; // or throw...

            if (Head.Next != null)
                Head = Head.Next;
            else
                Head = null;
        }
Beispiel #2
0
 public NodeList Dequeue()
 {
     NodeList node = list.Head;
     while(node.Next != null)
     {
         node = node.Next;
     }
     NodeList lastNode = new NodeList(node);
     node = null;
     return lastNode;
 }
Beispiel #3
0
        public void AddAtEnd(NodeList node)
        {
            if (Head == null)
            {
                Head = node;
                return;
            }

            NodeList curNode = Head;
            while (curNode.Next != null)
            {
                curNode = curNode.Next;
            }

            curNode.AddAfter(node);
        }
Beispiel #4
0
 public virtual void FillSubsets()
 {
     // storage for partitioned nodes
     initializePartitions();
     _repop = new NodeList<MCNodeData>();
     NodeList<MCNodeData> all = new NodeList<MCNodeData>(_graph.Nodes);
     while (all.Count > 0)
     {
         GraphNode<MCNodeData> gn = (GraphNode<MCNodeData>)all[0];
         Subsets[0].Add(gn.Value);
         //all.Remove(gn);
         _repop.Add(all[0]);
         all.RemoveAt(0);
         all = splitAllChild(all, gn, 0);
     }
     _graph.Nodes.Clear();
     foreach (var a in _repop)
         _graph.Nodes.Add(a);
 }
Beispiel #5
0
 public void AddAfter(NodeList node)
 {
     Next = node;
     node.Previous = this;
 }
Beispiel #6
0
 public void Push(NodeList node)
 {
     list.AddAtHead(node);
 }
Beispiel #7
0
 public Node Pop()
 {
     NodeList node = new NodeList(list.Head);
     list.RemoveAtHead();
     return node;
 }
Beispiel #8
0
 public void AddAtHead(NodeList node)
 {
     node.Next = Head;
     Head = node;
 }
Beispiel #9
0
 public LinkedList(NodeList node = null)
 {
     Head = node;
 }
Beispiel #10
0
        private NodeList<MCNodeData> splitAllChild(NodeList<MCNodeData> rem, GraphNode<MCNodeData> src, int loc)
        {
            for (int i = 0; i < src.Neighbors.Count; i++)
            {
                int locDest = src.Costs[i] == 1 ? 1 - loc : loc;
                if (!Subsets[0].Contains(src.Neighbors[i].Value) && !Subsets[1].Contains(src.Neighbors[i].Value))
                {
                    Subsets[locDest].Add(src.Neighbors[i].Value);
                    _repop.Add(src.Neighbors[i]);
                    rem.Remove((GraphNode<MCNodeData>)src.Neighbors[i]);
                    if (((GraphNode<MCNodeData>)src.Neighbors[i]).Neighbors.Count > 1)
                        rem = splitAllChild(rem, (GraphNode<MCNodeData>)src.Neighbors[i], locDest);
                }
                else
                {
                    _repop.Add(src.Neighbors[i]);
                    rem.Remove((GraphNode<MCNodeData>)src.Neighbors[i]);
                }
            }

            return rem;
        }
Beispiel #11
0
 public void Enqueue(NodeList node)
 {
     list.AddAtHead(node);
 }
Beispiel #12
0
 public Queue(NodeList node = null)
 {
     list = new LinkedList(node);
 }