inedges

Indices of the edges entering a node.

Category: Mathematics > Graph and Network Algorithms

Syntax

eid = inedges(D, nodeID)

Returns the indices of the edges that end at nodeID.

[eid, nid] = inedges(D, nodeID)

Also returns the nodes at the other end of those edges.

Description

Use the indices to read the weights or other columns of the edge table: D.Edges.Weight(inedges(D, n)) lists the weights of everything arriving at node n. predecessors gives only the neighboring nodes, while inedges identifies the edges themselves, which matters when there are parallel edges.

Input arguments

D
A digraph.
nodeID
A single node, as index or name.

Output arguments

eid
Column vector of edge indices, rows of D.Edges.
nid
Column vector of the source nodes of those edges.

Example

Edges arriving at node 4

D = digraph([1 1 2 3 4], [2 3 4 4 5], [1 4 2 1 3]);
eid = inedges(D, 4)'
D.Edges.Weight(eid)'
Output
eid = 1×2

     3     4
ans = 1×2

     2     1

See also

outedges predecessors indegree findedge