It seems not like an incidence matrix. Incidence matrix represents nodes connections. There are can be two approaches:

1. Terminals as graph nodes

IncTerminals = [1 1 0 0 1 0 0 0

1 1 0 0 0 0 1 0

0 0 1 1 0 1 0 0

0 0 1 1 0 0 0 1

1 0 0 0 1 1 0 0

0 0 1 0 1 1 0 0

0 1 0 0 0 0 1 1

0 0 0 1 0 0 1 1]

2. Nodes as graph nodes

IncNodes = [1 1 1 0

1 1 0 1

1 0 1 1

0 1 1 1]

But I can not remember wether it possible or not to convert incinence matrix to adjacency matrix or build a graph object with it.

But it is possible to build any kind of matrix or graph object if you would set edges as a pairs of nodes (check the doc for graph function). Again two ways:

1. Terminals as graph nodes

s = [1 1 2 3 3 4 5 7];

t = [2 5 7 4 6 8 6 8];

2. Nodes as graph nodes

s = [1 1 2 3];

t = [2 3 4 4];

Now you can create a graph object by

plotting it by

gives

1. Terminals

2. Nodes

Then you can extract from graph object any matrix you want

or

And the shortest path also

## 1 Comment

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/405821-find-lenght-of-shortest-path-from-nodal-incidence-matrix#comment_579038

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/405821-find-lenght-of-shortest-path-from-nodal-incidence-matrix#comment_579038

Sign in to comment.