Class FileSourceEdge

All Implemented Interfaces:
FileSource, Source

public class FileSourceEdge
extends FileSourceBase
Reader for the "edge" graph format.

The edge graph format is a very simple and lightweight format where each line describes an edge by giving two node names. The nodes are created implicitly.

This reader also understands the derivative format where a line contains a first node name, followed by several node names separated by spaces. In this case it links the first node with all other node name following on the line.

Also, the format does not specify any direction for edges. By default all edges are undirected. You can choose to make all edges directed by passing "true" as the first arguments to constructors FileSourceEdge(boolean) or FileSourceEdge(boolean, boolean) . The direction of edges goes from the first node name on each line toward the second (or more) node names on each line.

This format only contains edges. To ensure the "add node" events are sent before an edge referencing two nodes is created via an "add edge" event, this reader has a hash set of already encountered nodes. The hash set allows to issue "add node" events only when a node is encountered for the first time.

This hash set consumes memory, but is the only way to ensure "add node" events are correctly issued. If this input is directly connected to a graph, as graphs can create non-existing nodes automatically, you can disable the hash set of nodes using the constructor FileSourceEdge(boolean, boolean), and giving "false" for the second argument.

The usual file name extension for this format is ".edge".
  • Constructor Details

    • FileSourceEdge

      public FileSourceEdge()
      New reader for the "edge" format.
    • FileSourceEdge

      public FileSourceEdge​(boolean edgesAreDirected)
      New reader for the "edge" format.
      Parameters:
      edgesAreDirected - If true (default=false) edges are considered directed.
    • FileSourceEdge

      public FileSourceEdge​(boolean edgesAreDirected, boolean declareNodes)
      New reader for the "edge" format.
      Parameters:
      edgesAreDirected - If true (default=false) edges are considered directed.
      declareNodes - If true (default=true) this reader outputs nodeAdded events.
  • Method Details