0

如何为 DGML 文件中的边或链接添加权重或值?

<?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>

我希望能够为每个节点之间的线分配权重或值,以指定节点之间的强度。

4

2 回答 2

0

这是一个使用链接权重样式来执行此操作的示例:

<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>
于 2019-07-26T20:32:04.833 回答
0

您可以通过向每个链接源添加带有值的标签字段来为每个链接添加权重。这些数字将出现在图表上的箭头旁边。

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

此外,可以通过创建类别组并将该组分配给每个节点来更改每个节点的背景颜色。

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

<Node Id="a" Category="Orange" />
<Node Id="b" Category="Yellow" />
于 2016-10-03T17:20:01.667 回答