EdgeLabels for multiple edges

Is there a convenient, or even inconvenient, method to label edges in graphs with multiple edges? EdgeLabels → “Index” defaults to the first occurrence identical edges, i.e. all edges v2 → v3 have the same “Index”.

Since the edges on a graph may represent different states of the graph over time, it would be convenient to display the ordering of those transitions (edges). For example the transition: {v1 → v2, v2 ->v3,} versus the transition: {v4 → v2, v2 → v3}. The two v2 → v3 are distinct events yet I haven’t found an obvious option for giving them easily readable distinct labels.

I have tried adding EdgeWeight but EdgeWeight defaults to the first occurrence of an edge just as does “Index”. I’ve tried applying an index list to the edges but EdgeLabels still defaults to the first occurrence. I thought Tag might be an option but Tag isn’t implemented in Version 12.

It’s not clear to me that there’s a way to do this because ultimately a given graph is a collection of vertices and rules about which vertices are connected, regardless of what those edges might represent in terms of history/transitions/et c.

Fortunately, there’s a function that does this: EdgeTaggedGraph! Here’s a notebook where I look at this problem:

Thank you for your response. I’ll download the notebook , pull out my bigger hammer and see if I can make it work in MM-12 and with DirectedEdge.

Alas and alack, this doesn’t appear to work in MM-12. I tried several variations of your suggestion to no avail. MM-12 appears to interpret a 3-valued edge as a subgraph.

Here is one attempt using Insert[] instead of Append[]. I tried several variations, most of which generated errors.

PDF:

Input as text:

etLstX = {1 [DirectedEdge] 6, 1 [DirectedEdge] 6,
2 [DirectedEdge] 3, 3 [DirectedEdge] 3, 3 [DirectedEdge] 5,
3 [DirectedEdge] 6, 4 [DirectedEdge] 1, 4 [DirectedEdge] 1,
4 [DirectedEdge] 2, 4 [DirectedEdge] 4, 5 [DirectedEdge] 6,
5 [DirectedEdge] 8, 6 [DirectedEdge] 3, 6 [DirectedEdge] 4,
6 [DirectedEdge] 4, 6 [DirectedEdge] 5, 6 [DirectedEdge] 10,
8 [DirectedEdge] 9, 9 [DirectedEdge] 6, 10 [DirectedEdge] 4};
Graph[etLstX, EdgeLabels → “Index”]
xdx = 1;
Graph[DirectedEdge @@ Insert[#, xdx++, 2] & /@ etLstX, EdgeLabels → “Index”]
VertexList[%]

Okay, I hacked out something that sort of works. It doesn’t index EdgeLabels as I’d wanted but it does identify the occurrences of multi-edges by annotating the order of occurrence by showing the Position[] in the edge list of each occurrence. EdgeLabels[] still returns only the first occurrence of an edges but the EdgeLabel is now a list of occurrences:

(5 → 8) → {15, 16, 17, 18} tells me that the transition from v5 to v8 occurred at events {15, 16, 17, 18}

eLst is the EdgeList. eLab is the argument to EdgeLabels: EdgeLabels → eLab,

Method: (it ain’t pretty but it’s better than a poke in the eye)

eLab = Rule @@ {#, (Flatten[Position[eLst, #]])} & /@ eLst; :nerd_face: