示例#1
0
        int?MaxDistanceBetweenVertices(VertexedLinkedListNode root)
        {
            int count = 0;
            int?start = null, end = null;
            VertexedLinkedListNode cur = root;

            while (cur != null)
            {
                count++;
                if (cur.IsVertex)
                {
                    if (start == null)
                    {
                        start = count;
                    }
                    else
                    {
                        end = count;
                    }
                }
                cur = cur.next;
            }
            return(end - start);
        }
示例#2
0
 public VertexedLinkedListNode(int data, VertexedLinkedListNode next, bool IsVertex)
 {
     this.data = data;
     this.next = next;
     this.IsVertex = IsVertex;
 }
示例#3
0
 public VertexedLinkedListNode(int data, VertexedLinkedListNode next, bool IsVertex)
 {
     this.data     = data;
     this.next     = next;
     this.IsVertex = IsVertex;
 }
示例#4
0
 int? MaxDistanceBetweenVertices(VertexedLinkedListNode root)
 {
     int count = 0;
     int? start = null, end = null;
     VertexedLinkedListNode cur = root;
     while (cur != null)
     {
         count++;
         if (cur.IsVertex)
         {
             if (start == null)
                 start = count;
             else
                 end = count;
         }
         cur = cur.next;
     }
     return end - start;
 }