0

How do I add weight or value to the Edges or Link in a DGML file?

<?xml version='1.0' encoding='utf-8'?>
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
  <Nodes>
    <Node Id="a" Label="a" Size="10" />
    <Node Id="b" Background="#FF008080" Label="b" />
   <Node Id="c" Label="c" Start="2010-06-10" />
 </Nodes>
  <Links>
    <Link Source="a" Target="b" />
    <Link Source="a" Target="c" />
  </Links>
  <Properties>
    <Property Id="Background" Label="Background" DataType="Brush" />
    <Property Id="Label" Label="Label" DataType="String" />
    <Property Id="Size" DataType="String" />
    <Property Id="Start" DataType="DateTime" />
  </Properties>
</DirectedGraph>

I would like to be able to assign a weight or value to the lines between each node to designate the strength between the nodes.

Kahlan
  • 55
  • 2
  • 11

2 Answers2

0

You can add weights to each link by adding a label field with a value to each of the Link Sources. The numbers will appear beside the arrows on your graph.

<Link Source="a" Target="b" Label="5" />
<Link Source="a" Target="c" Label="6" />

Additionally, the background color of each node can be changed by creating Category groups and assigning that group to each node.

<Category Id="Orange" Background="Orange" />
<Category Id="Yellow" Background="Yellow" />

<Node Id="a" Category="Orange" />
<Node Id="b" Category="Yellow" />
Kahlan
  • 55
  • 2
  • 11
0

Here's an example that uses a link Weight Style to do it:

<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
  <Nodes>
    <Node Id="Banana" UseManualLocation="True" />
    <Node Id="Test" UseManualLocation="True" />
  </Nodes>
  <Links>
    <Link Source="Test" Target="Banana" Priority="10"/>
    <Link Source="Test" Target="Green" />
  </Links>
  <Properties>
    <Property Id="Bounds" DataType="System.Windows.Rect" />
    <Property Id="UseManualLocation" DataType="System.Boolean" />
  </Properties>
  <Styles>
    <Style TargetType="Link">
      <Setter Property="Weight" Expression="Priority" />
    </Style>
  </Styles>
</DirectedGraph>
Chris
  • 1,101
  • 8
  • 13