This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Returns the "best" incident edges.

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


Graph::getBestAdjacentEdge(G, Vertex, Vertices, <Min | Max>, <Weights | Costs>)


Graph::getBestAdjacentEdge(G, Vertex) returns the best incident edge according to specified attributes.

Graph::getBestAdjacentEdge(G, Vertex, Vertices) returns a vertex v out of Vertices. The best edge is (Vertex, v) according to the specifications.


Example 1

Let us create a graph and find out the edge with the least weight:

G1 := Graph([1, a, 3, 4], [[1, a], [1, 3], [1, 4]], 
            EdgeWeights = [10, 20, 30],
            EdgeCosts = [30, 20, 10]):
Graph::getBestAdjacentEdge(G1, [1], Graph::getVertices(G1)), 
Graph::getBestAdjacentEdge(G1, [1], Graph::getVertices(G1),
                                             Min, Weights)

The result shows that edge [1, a] has the least weight. It also shows that Min and Weights are the defaults if omitted. Next, we want to know the edge with maximum weight:

Graph::getBestAdjacentEdge(G1, [1], Graph::getVertices(G1), Max)

The vertex with maximum weight is edge [1,4]. Now we have a look at the costs. The minimum cost edge can be found with:

Graph::getBestAdjacentEdge(G1, [1], Graph::getVertices(G1), Costs)

So the vertex with maximum weight is also the edge with minimum costs. Finally let us search for the edge with maximum costs:

Graph::getBestAdjacentEdge(G1, [1], Graph::getVertices(G1),
                                               Costs, Max)



A graph


One vertex of G.


Vertices in G.



If stated, the edge with the minimum attribute will be found. (Default)


If stated, the edge with the maximum attribute will be found.


If stated, edge weights will be used for comparison. (Default)


If stated, edge costs will be used for comparison.

Return Values


Was this topic helpful?