コード例 #1
0
ファイル: Program.cs プロジェクト: prolificcoder/csharpcoding
        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
ファイル: Program.cs プロジェクト: prolificcoder/csharpcoding
 public VertexedLinkedListNode(int data, VertexedLinkedListNode next, bool IsVertex)
 {
     this.data = data;
     this.next = next;
     this.IsVertex = IsVertex;
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: prolificcoder/csharpcoding
 public VertexedLinkedListNode(int data, VertexedLinkedListNode next, bool IsVertex)
 {
     this.data     = data;
     this.next     = next;
     this.IsVertex = IsVertex;
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: prolificcoder/csharpcoding
 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;
 }