I am not sufficiently familiar with the R interface of igraph to give advice here, but I wanted to draw a comparison with how Mathematica does this. There is a HighlightGraph function which can mark one or several sets of vertices, edges or subgraphs. Visualizing any kind of subgraph (paths, cycles, communities, etc.) is a short one-liner. I wish this could be done this easily in R and Python.

Note that this did not involve a permanent modification of the graph that one might want to undo later, such as the setting the color attribute in the example above.

Well, technically speaking, HighlightGraph returns a modified graph which encodes what needs to be highlighted in a special graph attribute (not quite the same as setting the base colours). This paradigm of returning modified objects instead of mutating objects in place fits functional language, so it would be a nice way to handle visualization in R as well, if someone is up for implementing it. If we were to mimic how Mathematica’s system works, there could be a function highlight_graph(graph, object) where object may be a vertex sequence, an edge sequence, or another graph whose vertices are a subset of that of graph. The generalized version would take a list of objects instead of a single object, to highlight multiple things in multiple colours.

However, easier to implement and nice to have, is edgelist_from_literal, analogous to graph-from_literal. That would improve the usability of the path class. For example.

edgelist_from_literal(...) |> graph_from_edgelist() -> g