Node Pair list from a graph

3 vues (au cours des 30 derniers jours)
Hari
Hari le 4 Oct 2020
Commenté : Hari le 4 Oct 2020
How can I get a matrix of node pairs from a graph? That is, if there are 4 nodes 1,2,3,4, then the node pair matrix would be :
1 2
1 3
1 4
2 3
2 4
3 4
I could do this using 2 for loops, but is there any quick way of doing it?

Réponse acceptée

Bruno Luong
Bruno Luong le 4 Oct 2020
nchoosek(1:4,2)
  1 commentaire
Hari
Hari le 4 Oct 2020
Thanks :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by