I'm trying to highlight the path between two vertices, and it seems that PathGraph
along with HighlightGraph
is what I should use. However, only the vertices of the path graph get highlighted. The edges between the vertices are not being highlighted.
Here's my code:
G =
Graph[
{1 -> 3, 1 -> 9, 3 -> 4, 4 -> 3, 3 -> 7, 4 -> 1, 4 -> 8, 4 -> 2, 9 -> 2,
9 -> 10, 5 -> 9, 2 -> 5, 2 -> 7, 10 -> 2, 7 -> 10, 7 -> 8, 7 -> 2, 8 -> 6,
8 -> 7, 6 -> 8, 6 -> 7 },
GraphStyle -> "SmallNetwork"]
I'll get the following:
Now for my attempt at highlighting the shortest path between vertex 1 and 5:
HighlightGraph[G, PathGraph[FindShortestPath[G, 1, 5]]]
I get the following:
What am I doing wrong? I'd like for the arrows leading from vertex 1 to 5 to be highlighted too.