Skip to content
Huston Hedinger edited this page Nov 20, 2013 · 1 revision

edge keys

Edges make up the connections between nodes and have a very similar data structure to nodes themselves. Edges are always directed, meaning that a source and target node are always specified. Depending on the use case, the 'direction' of the edge may or may not be relevant. Graphs can contain disconnected nodes, and so strictly speaking, edge dictionaries are not required for all nodes in a GraphJSON object.

edges is a list of dictionaries containing the following top level keys:

  • source
  • target
  • type
  • properties
  • caption
  • edgeMeta

example:

{
    edges: [
        {
            source: 1234,
            target: 4321,
            properties: {...},
            type: [...],
            caption: "something to display!",
            edgeMeta: {...},
    ],
...
}

usage

(unique str or int) contains the value of the node id where the edge will start/end. The values passed to source or target must match a unique node id value. While some nodes in a GraphJSON object may be disconnected, all edges require a source and target node id value, and cannot be 'disconnected.'

example:

...
source:
target:
...

(str, optional) an edge may have at most one type. Often times convention is to write edge types in upper case. For instance, "FATHER_OF", "FOLLOWS", "GRADUATED_FROM", "DEPENDS_ON", "HAS_ACCESS", etc. While each edge can only store one type, two nodes may have multiple edges between them. For instance, node: "Mother", and node: "Son" have a "PARENT_OF" edge between them, and they may also share a "FRIENDS" edge, as well as a "LIVES_WITH" edge.

...
"some_json"
...

(dict, optional) Just like node objects, each edge can contain an arbitrary number of properties as a dictionary of keys that store values or lists of values. The keys and values of properties can be shared in common with other edges or can be unique to the edge holding them - for instance, "is_current", "begin_date", "strength", "is_public", or "category". Properties can be used in the application layer for analytics, filtering of the data, and in several other ways.

...
"some_json"
...

(str, optional) similar to node caption, is a universal parameter to describe what will display upon interacting with a an edge (for instance onClick or hover). The caption need not be unique for each edge, and and will often times be one of the values supplied by properties or type.

...
"some_json"
...

(dict, optional) is a dictionary of values that defines important information about edges for the application. Settings assigned to an edge via the edgeMeta will override any settings defined in the top level GraphJSON meta key. edgeMeta can include the keys directed and edgeStyle,

  • bidirectional: (bool, optional) by default bidirectional is "false" so that GraphJSON allows applications to access directed information about edges in the GraphJSON. However, often times directionality may be less important - for instance, two family members that "ARE_RELATED" in contrast to a "FATHER_OF" type, or a Facebook "FRIEND" edge, in contrast to a Twitter "FOLLOWS" edge. In this case - by setting directed to "false" GraphJSON indicates to the visualization or analytics package that this particular relationship is bidirectional without needing to specify the edge twice.
...
type: "SIBLING_OF",
directed: false,
...
  • edgeStyle is a dictionary that can include any of the following keys:
    • stroke: is a css color value for the edge
    • strokeWidth: is an integer pixel value for the thickness of the edge
    • straight: a boolean value set to true by default. If straight: "false" the edge will be curved.
    • arrows: is a boolean value set to false by default. If arrows is set to "true", the edge will display arrows in a specific direction. *Note: If arrows: "true" and directed: "false", arrows will display in both directions.
Clone this wiki locally