SharpPlot Reference > SharpPlot Methods > DrawNetworkMap Method

SharpPlot.DrawNetworkMap Method

Draw a network of nodes and their mutual link strengths, represented by line widths.


sp = new SharpPlot(180,120);
// Network is not oriented - matrix is triangular
series = new int[][] {new int[0],new int[] {13},new int[]{2,12},new int[]{3,3,36},
         new int[]{3,3,1,3},new int[]{4,21,12,8,2},new int[]{44,1,2,3,9,3},new 
         int[]{4,1,46,8,1,14,50},new int[]{36,29,1,3,1,25,17,8},new int[]{11,1,8,6,
sp.SetColors(new Color[]{Color.Navy,Color.Gray});  // Nodes, Links
sp.SetNetworkMapLinkArc(0);  // Flat links
sp.NetworkMapStyle = (NetworkMapStyles.NoAxes|NetworkMapStyles.OnTopMarkers|

The short tutorial shows a few of the possibilities and some sample code.



Link data is a square matrix with as many rows and colums as the number of nodes in the network. Each series is, for a given origin node, the list of link strengths to all other nodes (including to itself at the diagonal of the matrix). This can be inversed (transposed) with DataStyles.Rows so that data is given for each destination node. In all cases link-wise settings are taken in the same order as the input data – such as SetNetworkMapLinkArc, SetValueTags, SetValueNudge, or SplitBy with NetworkMapStyles.SplitByLink).

Links generally go clock-wise unless using NetworkMapStyles.CounterClockwise, and can be individually reversed where data is negative.

Coordinates may be given for nodes, otherwise nodes are automatically spread on circles (or lines if using NetworkMapStyles.Horizontal or NetworkMapStyles.Vertical). In the latter case, if nodes are SplitBy, then each category is on a different circle (inner -> outer) or line (ascending coordinates).

A NetworkMap first output the nodes, consuming one Color, Marker, and Pen Width, and outputting one Key for each category of node, then it outputs the links, consuming one Color, LineStyle and Pen Width, and outputting one Key for each category of link.

Nodes can be split into several categories using SplitBy. Links can be made to reuse their origin node attributes with NetworkMapStyles.SplitByOrigin, or of their destination node with NetworkMapStyles.SplitByDestination.

SplitBy can be made to affects links instead with NetworkMapStyles.SplitByLink. Then nodes are not split, unless using NetworkMapStyles.SplitByOrigin or NetworkMapStyles.SplitByDestination, in which case nodes re-use the attributes of the link to themselves.

Keys can be disabled with NetworkMapStyles.NoNodeKey or NetworkMapStyles.NoLinkKey.

Links are drawn with circle arcs, which vary from flat lines (infinite radius, zero angle) for nodes that are furthest apart, to half-circles (the smallest possible radius, or largest possible angle) as nodes get closer to each other. This strategy generally works well when nodes are laid out on a circle (the default).

Arcs can be fixed with NetworkMapStyles.FixedArcs, and fine control over individual arcs can be set with SetNetworkMapLinkArc and SetNetworkMapSelfArc.

See also ...

Network Map for nodes and links | SharpPlot Members | SharpPlot.NetworkMapStartAngle Property | SharpPlot.NetworkMapStyle Property | SharpPlot.SetNetworkMapLinkArc Method | SharpPlot.SetNetworkMapSelfArc Method

Send comments on this topic
© Dyalog Ltd 2016