I have the following code which gives me some random complete graph

rand = {1, 2, 3};
el = EdgeList[CompleteGraph[5]];
g = CompleteGraph[5, VertexLabels -> "Name", 
  EdgeLabels -> Table[el[[i]] -> RandomChoice[rand], {i, Length[el]}]]

What I want is to get every possible graph with edges labeled with numbers from rand.

  • $\begingroup$ I wanna get every graph in some sort of cycle like For because every iteration I should do something with the graph I've got. $\endgroup$
    – mclord
    Commented Dec 22, 2021 at 19:01
  • $\begingroup$ Are you sure you need all those labeled graphs? Look at the result of Tuples[{1, 2, 3}, 10], for instance. $\endgroup$ Commented Dec 22, 2021 at 19:03
  • $\begingroup$ I'm pretty sure I need all of them since I should counts paths in all this graphs. $\endgroup$
    – mclord
    Commented Dec 22, 2021 at 19:11
  • 2
    $\begingroup$ To make the hint in my previous comment more explicit: there are $59049$ of those labeled graphs. If you absolutely must, this question might be of interest. $\endgroup$ Commented Dec 22, 2021 at 19:17
  • $\begingroup$ I feel like we have 3 possibilities for each edge, and are there 3^(10*9/2) (=2954312706550833698643) of those labeled graphs? Of course, a lot of these graphs are isomorphic, and we have to figure out how to get rid of them. $\endgroup$
    – licheng
    Commented Dec 23, 2021 at 2:27


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.