I have a root Subgraph
object with four child Subgraphs
each containing a few Nodes
. I have added all the Subgraphs
and Nodes
to the Graph
and set the RootSubgraph
on the Graph
. However, when trying to draw the Graph
I get a cast error from within the library (Microsoft.Msagl.GraphViewerGdi.Draw.cs
, line 1044) where the GeometryNode
of a Subgraph
is cast to a Cluster
. The GeometryNode
is set to a Cluster
in GeometryGraphCreator.ProcessSubgraphs
and the error message gives me no information about why the cast fails. How can I fix this?
For now I've simply set the Label
to null to avoid the drawing code but I would like to use a label eventually.
The problem was in my initialisation of the Subgraph
:
var subgraph = new Subgraph(id)
{
Attr =
{
Id = id,
FillColor = fillColor,
},
Label =
{
FontSize = 10,
Text = id
}
};
Assigning the Label
property this way skipped some extra set up code needed to correctly link the Label
with the Subgraph
. Leaving it out altogether lets the constructor handle the Label
itself.