Bug introduced in 10.0 or earlier and fixed in 12.0
Note: Associations are new in 10.0
Here is a nice graph whose vertices are Associations
:
g = Graph[{
<|"n" -> 1|> -> <|"n" -> 2|>,
<|"n" -> 1|> -> <|"n" -> 3|>,
<|"n" -> 2|> -> <|"n" -> 4|>,
<|"n" -> 3|> -> <|"n" -> 4|>},
VertexLabels -> Automatic]
Several graph functions work as expected, e.g., AcyclicGraphQ[g]
and AdjacencyMatrix[g]
.
However, functions that refer explicitly to the vertices don't work:
GraphDistance[g, <|"n" -> 2|>, <|"n" -> 4|>]
"GraphDistance: Unknown option "n" in GraphDistance."
Or:
GraphDistance[g, <|"n" -> 2|>]
"GraphDistance: GraphDistance called with 1 argument; 2 or 3 arguments are expected."
It looks like it's interpreting the Association
as a bunch of options to GraphDistance
. Is that use of Associations
documented somewhere?
(It seems that using non-integer vertices causes problems: link.)