A graph in SystemWeaver is made up of nodes (points) and edges (lines). In the Graphs view, the nodes and edges are drawn into the view according to the configuration and automatic layout and routing methods. The view offers broad support in that it can be used with any type of model that has relations between SystemWeaver objects (i.e., items, parts, nodes). It also supports the creation of sequence diagrams. In this article, we describe the basics of graph configuration in SystemWeaver to get you started.

Prerequisites


Types of Graphs

The view can be used to graphically visualize any type of data model. 


Examples




Sequence Diagrams

With release R38, our configurable graph view offers a first version of a sequence diagram. Learn more about sequence diagram configuration in the application Help.



Configuring the View

A configurable graph is a Config item and is created using the config item Sandbox mode as described in Creating Config Item Views. By default, the Sandbox will include a few basic elements of a configuration to get you started, as shown below.  



Tip: A quick way to create a new graph is to copy a similar one that is already defined as described in Creating a New Config Item by Copying an Existing .


The basic building blocks of graphs are nodes A and edges B.


Example Configuration

Below is the configuration for the graph shown above.

<Graph>  
    <ForEachPart type="3EFL"> 
        <Node>
            <DefObj> 
                <ForEachPart type="3PEN">  
                    <DefObj>
                        <Node/>
                    </DefObj>
                </ForEachPart>
            </DefObj>
        </Node>
    </ForEachPart>
    <ForEachPart type="XESX">
        <Node>
            <DefObj>
                <ForEachPart type="EXAC">
                    <DefObj>
                        <Node>
                            <Variable name="component" as="Item" select="."/>
                            <ForEachPart type="3E2F">
                                <DefObj>
                                    <Edge from="$component" to="."/>
                                </DefObj>
                            </ForEachPart>
                        </Node>
                    </DefObj>
                </ForEachPart>
            </DefObj>
        </Node>
    </ForEachPart>
</Graph>
Tip: See Finding SystemWeaver Type Identifiers (SIDs) for how to find the SIDs you will need.


Explanation of the Configuration Elements

<Graph> along with its sub-elements, defines one specific graph.


<Node/> defines a node to be included (drawn) as a box in the view A. By default, the label of the node will be the Name of the object you have selected in the structure tree.



The Node tag has seven optional attributes: 

  • style can be used to apply a node style. See Defining Node and Edge Styles in Graphs.
  • caption can be used to change the label of the node.
  • group can be used to organize and layout the node within a declared node group. Refer to NodeGroup in the application Help for further details.

Nodes can be placed inside other nodes to form a hierarchy.

<Graph> 
  <Node>
    <ForEachPart type="EXAC">
      <DefObj> 
        <Node/>
      </DefObj>
    </ForEachPart>
  </Node>
</Graph>

  • columnId is defined when using GraphTable. It references a predefined GraphColumn. Supported values are String and Path Query values. Examples: 
    <Node columnId="Col-1"/> 
    <Node columnId="#{? 'C_' + Handle}"/>
    • rowId is defined when using GraphTable. It references a predefined GraphRow. Supported values are String and Path Query values. Examples: 
      <Node rowId="Row-1"/> 
      <Node rowId="#{? 'R_' + Handle}"/>
  • id can be used to define a custom id for a graph node. The use case for using a custom id is to define a dummy node, i.e., a node that does not represent an object in the database. If id is not defined, the node will, by default, get the current object's handle as id.  Supported values are String and Path Query values that result in a single/list of strings. Examples: 
    <Node id="id-1"/>
    <Node id="#{? 'dummy_' + Handle}"/> 
  • objects can be used to define the objects in the tree structure (SystemWeaver Item, Part, or Node) to be highlighted when clicking on a node in the graph. Note that if the objects attribute is not defined, the graph engine will try to fall back on the id attribute. In that case, the id attribute must contain a valid single/list of SystemWeaver Handle, otherwise the highlighting functionality will not work. Supported values are Path Query values that result in a single/list of SystemWeaver objects.
    <Node objects="."/> 
    <Node objects="/SID1/SID2"/>

<Edge> defines one or many edges to be included (drawn) as a line between nodes in the view. Edges have a direction and are established between two items or parts. The tag has six attributes. 


The from and to attributes are required. Supported values are Path Query values that result in a single/list of strings/SystemWeaver objects. 

  • from defines the node the edge is pointing from. 
  • to defines the node the edge is pointing to.  


  • style is optional, and can be used to apply an edge style. See Defining Node and Edge Styles in Graphs.
  • caption is optional, and defines the method for assigning a caption value to the edge. Two predefined variables can be used in the assignment, named "from" and "to", and the attribute values will be used for each edge created according to the <Edge> definition. The variables can be used arbitrarily in the caption attribute to define the caption rule, e.g.,:
    <Edge from="." to="/P001.OrderBy(Name)" caption="$from.Name + '' - '' + $to.Name"/>
  • id, is optional, and can be used to assign a custom id to a graph edge. If the id is not defined, the edge will not get an id. Supported values are String and Path Query values that result in a single/list of strings. Examples: 
    <Edge id="id-1"/>
    <Edge id="#{? 'x_' + Handle}"/> 
  • objects is optional, and can be used to define the objects in the tree structure (SystemWeaver Item, Part, or Node) to be highlighted when clicking on an edge in the graph. Note that if the objects attribute is not defined, the graph engine will try to fall back on the id attribute. In that case, the id attribute must contain a valid single/list of SystemWeaver Handle, otherwise the highlighting functionality will not work. Supported values are Path Query values that result in a single/list of SystemWeaver objects. Examples: 
    <Edge objects="."/>
    <Edge objects="/SID1/SID2"/> 


The Edge tag can be used in three different ways:
  • Implicit "to": <Edge from=""/>
    With this method, the current node will be used as the "to" node.

  • Implicit "from": <Edge to=""/>
    With this method, the current node will be used as the "from" node.

  • Explicit "to" and "from": <Edge from="" to=""/>
    With this method, both the "to" and "from" node(s) are explicitly specified.

Optional Graph Sub-Elements

Depending on your use case, you may want to apply some of the available optional elements to your graph configuration. Below are some of them. A complete list can be found in the application Help.


Editable

The <Editable> tag, when included in the <Options> tag, specifies if a graph is editable or not as defined by its value attribute and/or definition. If editable, users can graphically design the data directly in the graph. Valid values are "true" or "false". The default value is "true". If there is at least one of the following tags added to the graph definition, the graph will provide the Edit option on the graph toolbar automatically:

  • AddPart
  • RemovePart
  • Connect node

Note: If none of the above tags are included to the graph definition, the Edit option will not show up in the view, even if Editable is set to "true". Editability can also be turned off, by setting the option to "false". 


To learn more about configuring the AddPart, RemovePart, and Connect node elements, refer to the application Help.

 

Legend

The Legend option is combined with adding legendLabel attributes to NodeStyle and EdgeStyle tags to provide a Legend pane for users. The legend can be activated to help explain the content of the graph. Refer to Legends in Configurable Graphs for more information.


ObjIcons

The <ObjIcons/> tag, when included in the <Options> tag, enables you to display the icons used in the SystemWeaver metadata in the graph nodes as described in Defining Node and Edge Styles in Graphs. 


NodeStyles

The NodeStyles tag along with its sub-elements can be used to define the styles of the nodes as described in Defining Node and Edge Styles in Graphs


EdgeStyles

The EdgeStyles tag along with its sub-elements can be used to define the styles of the edges as described in Defining Node and Edge Styles in Graphs.


PortStyles

The PortStyles tag along with its sub-elements can be used to define the styles of the ports.


InPort,  OutPort and Bi-directional Port

InPorts and OutPorts are used to easily model the implicit connection concept used in SystemWeaver. In this case there is no need to define edges. The graph itself will identify the edges based on the InPort and OutPort elements. An InPort(A) is added to indicate incoming communication. An OutPort (B) is added to indicate outgoing communication.



Below is a configuration showing how to use OutPort and InPort. The connection attribute indicates what item or part is used to identify the connection. In this example, an OutPort will generate an edge to an InPort that has the same item or part as the connection object.

<Graph> 
  <ForEachPart type="XESX">
    <Node>
      <DefObj>
        <ForEachPart type="EXAC">
          <DefObj> 
            <Node>            
              <ForEachPart type="ITOS">                           
                <DefObj>  
                  <OutPort connection="."/>              
                </DefObj>
              </ForEachPart>
              <ForEachPart type="ITIS">                          
                <DefObj>  
                  <InPort connection="."/>              
                </DefObj>
              </ForEachPart>         
            </Node>    
          </DefObj>
        </ForEachPart>
      </DefObj>
    </Node> 
  </ForEachPart>
</Graph>


The InOutPort can be used for bi-directional ports.

<Graph> 
<ForEach select="/ITFC">
<Node>
<ForEach select="/part::ARRP">
<InPort connection="DefObj"/>
</ForEach>
<ForEach select="/part::ARPP">
<OutPort connection="DefObj"/>
</ForEach>
<ForEach select="/part::ARINO">
<InOutPort connection="DefObj"/>
</ForEach>
</Node>
</ForEach>
</Graph>




Viewing the Graph Data in XML

To see the graph data in XML (not to be confused with the XML Definition) resulting from the definition, you can use the Ctrl + Shift + X key shortcut, which opens a pane where the XML can be observed, and even modified, for testing purposes.



What's Next?

You can also learn more about graph scripting options in XML Tag Reference - Graph specific in the SystemWeaver Script Language Reference Manual in the Help.