Documentation Center

  • Trial Software
  • Product Updates

Contents

Graph::getBestAdjacentEdge

Returns the "best" incident edges.

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

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

Description

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.

Examples

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)

Parameters

G

A graph

Vertex

One vertex of G.

Vertices

Vertices in G.

Options

Min

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

Max

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

Weights

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

Costs

If stated, edge costs will be used for comparison.

Return Values

Vertex

Was this topic helpful?