Documentation

findedge

Locate edge in graph

Syntax

idxout = findEdge(g,s,t)
[sout,tout] = findedge(g)
[sOut,tOut] = findedge(G,idx)

Description

example

idxOut= findedge(G,s,t)returns the numeric edge indices,idxOut, for the edges specified by the source and target node pairsst. The edge indices correspond to the rowsG.Edges.Edge(idxOut,:)in theG.Edgestable of the graph. An edge index of0指示图中不在图中的边缘。

example

[Sout,tOut] = findedge(G)returns the source and target node IDs,SouttOut, for all of the edges in graphG.

example

[Sout,tOut] = findedge(G,idx)finds the source and target nodes of the edges specified byidx.

Examples

collapse all

创建图形,然后确定(1,2)和(3,5)边缘的边缘索引。

s = [1 1 2 2 2 3 3 3]; t = [2 3 3 4 5 6 7 5]; G = graph(s,t)
G = graph with properties: Edges: [8x1 table] Nodes: [7x0 table]
idxOut = findedge(G,[1 3],[2 5])
idxOut =1 - 6

idxOutcontains the row index intoG.Edges.EndNodesfor each specified edge.

Create a graph, and then determine the end nodes of all edges in the graph.

s = {'a''a''b''b''c''c'}; t = {'b''c''d''e''f''g'}; G = graph(s,t)
G = graph with properties: Edges: [6x1 table] Nodes: [7x1 table]
[sout,tout] = findedge(g)
sout =1 1 2 2 3 3
tOut =2 3 4 5 6 7

Create a graph, and then determine the end nodes for the edges whose indices are37.

s = [1 1 1 1 2 2 3 3 4 4]; t = [2 3 4 5 6 7 8 9 10 11]; G = digraph(s,t)
G = digraph with properties: Edges: [10x1 table] Nodes: [11x0 table]
[sOut,tOut] = findedge(G,[3 7])
sout =1 3
tOut =4 8

Create a graph.

s = [1 1 2 3]; t = [2 3 3 4]; weights = [10 20 30 40]; G = graph(s,t,weights)
G = graph with properties: Edges: [4x2 table] Nodes: [4x0 table]

Find the weight of the (1,3) edge, usingfindedgeto retrieve the index.

G.Edges.Weight(FindEdge(G,1,3))
ans = 20

可使ut Arguments

collapse all

可使ut graph, specified as either agraph或者digraphobject. Usegraphto create an undirected graph ordigraphto create a directed graph.

Example:G = graph(1,2)

Example:G = digraph([1 2],[2 3])

不de pairs, specified as scalars, vectors, character vectors, or cell arrays of character vectors. Similarly located elements instspecify the source and target nodes that form edges in the graph.

Example:G = findedge(G,[1 2],[3 4])

Example:G = findedge(G,{'a' 'a'; 'b' 'c'},{'b' 'c'; 'c' 'e'})

Edge indices, specified as a scalar or vector of positive integers. The edge index corresponds to a row in theG.Edgestable of the graph,G.Edges(idx,:).

Output Arguments

collapse all

边缘索引,作为非负整数的标量或向量返回。边缘索引对应于行G.Edgestable of the graph,G.Edges(idxOut,:). An edge index of0指示图中不在图中的边缘。

不de IDs, returned as separate scalars or vectors of positive integers. Similarly located elements inSouttOutspecify the source and target nodes that form the edgesG.Edges(idx,:).

在R2015B中引入

Was this topic helpful?