1

From an adjacency matrix I have to get the vertex of a path between two nodes doesn't care the weight

enter image description here

Not sure how to do it well.

    /// <param name="start"></param>
    /// <param name="end"></param>
    /// <returns>Returns the path in vertice</returns>
    /// <Complexity>O(n)</Complexity>

    public string[] GetPath(string start, string end)
    {
        int startPosition = 0; //start position 
        int endPosition = 0;  //end position

        for (int i = 0; i < Vertices.Length; i++)
        {                
            if(Vertices[i] == start)
            {
                startPosition = i;
            }
            if (Vertices[i] == end)
            {
                endPosition = i;
            }
        }

        string[] path = new string[0];

        for (int j = 0; j < Vertices.Length; j++)
        {
            if (j >= startPosition && j <= endPosition) {
            }
        }
        return path;
    }

and shortest path

public string[] GetShortestPath(string start, string end)
{
 //In this one must return the vertex of shortest path between the nodes but checking the weight
}

Hope you can help me.

1
  • if you do not have any hit about the direction the only thing left to do is to check all directions
    – NtFreX
    Commented Nov 28, 2016 at 0:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.