5
$\begingroup$

I tried to find the fundamental cycles of a multiple edge graph below, but it doesn't seem to work. Is it true that the built-in function FindFundamentalCycles does not work with multiple edge graphs? Or did I make a mistake or not understand the function?

g = Graph[{1 <-> 2, 2 <-> 3, 3 <-> 2, 1 <-> 3}, 
   VertexLabels -> "Name"];
cycle = FindFundamentalCycles[g];
HighlightGraph[g, #] & /@ cycle

enter image description here

Version: 12.1.1 for Microsoft Windows (64-bit)

$\endgroup$
0

2 Answers 2

5
$\begingroup$

A workaround for highlighting a multigraph from @HenrikSchumacher answer.

g = EdgeTaggedGraph[{1 <-> 2, 2 <-> 3, 3 <-> 2, 1 <-> 3}, 
   VertexLabels -> "Name"];
cycle = FindFundamentalCycles[g];
HighlightGraph[g, EdgeList[g][[EdgeIndex[g, #] & /@ #]]] & /@ cycle

enter image description here

$\endgroup$
4
$\begingroup$

Mathematica's implementation of multigraphs is called EdgeTaggedGraph. So better use the following

g = EdgeTaggedGraph[{1 <-> 2, 2 <-> 3, 3 <-> 2, 1 <-> 3}, 
   VertexLabels -> "Name"];
cycle = FindFundamentalCycles[g]
{
 {UndirectedEdge[3,1,1],UndirectedEdge[1,2,1],UndirectedEdge[2,3,1]}, 
 {UndirectedEdge[3,1,1],UndirectedEdge[1,2,1],UndirectedEdge[2,3,2]}
}

However, HighlightGraph does not seem to be able to highlight these cycles correct. (At least not in version 13.3 that I am using at the moment.)

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.