예제 #1
0
    public void AddDirectedEdge(int source, int destination, int weight = 0)
    {
        Vertice sourceVertice      = GetVertice(source);
        Vertice destinationVertice = GetVertice(destination);

        if (sourceVertice == null || destinationVertice == null)
        {
            throw new ArgumentException("Given source value or destination value doesn't exist in graph.");
        }

        if (!sourceVertice.ContainsEdge(destinationVertice))
        {
            sourceVertice.AddEdge(destinationVertice, weight);
        }
    }