Skip to content
Sam Sarjant edited this page Nov 17, 2013 · 10 revisions

The DAG is essentially made up of two types of objects: nodes, which represent named entities which may specify non-inference-related properties (e.g. internal properties, or properties which do not need to be inferred over); and edges, which represent the connections between nodes (e.g. assertions) and can be inferred over.

Getting Started

The DAG can be accessed in two separate manners: directly loading it as a Java object and acting upon it via the DirectedAcyclicGraph class, or via Command Line Interface (CLI) by telnetting to the appropriate socket on the machine in which the DAG is running. Either case requires some Java code to be run: include the DAG in the classpath of the project accessing it, or run the main method (usually in the background) of DAGCommandLineInterface.

The latter option also accepts some arguments:

  • -r Specify the root directory of the DAG (as it stores all nodes/edges.
  • -p Specify the port number for connecting to the DAG via CLI
  • -n Specify the number of nodes to keep cached in local memory (ordered by last accessed)
  • -e Specify the number of edges to keep cached in local memory (ordered by last accessed)

Run the CLI using: java -Xms1G -Xmx24G -server -cp "lib/*:bin" graph.core.cli.DAGCommandLineInterface

Connect using: telnet . You may create as many connections as you please (i.e. it allows concurrent read/write access). At this point you are taken to a prompt. Type list to list the available commands.

Using the CLI

You can always type list to view the available commands, and type help to get a more detailed description of the command.

The CLI is flexible in how you choose to write nodes. A DAG node can be written by its name or its unique ID (that is, all numbers are interpreted as IDs). Names can be surrounded in quotes when created via addnode, but will be interpreted as Strings otherwise. Speaking of which, writing a String (not stored as a node) is a matter of adding quotes to either side of the String text (e.g. "doggie"). Primitive values, such as true, 43, c, and 3.14159 are all written by prefixing a single ' before the value. This is automatically parsed into the most appropriate primitive value and always displayed with a quote preceding the value. These are also not stored as nodes.

Core DAG commands

As at 8/8/2013.

  • addedge - Creates and adds a new edge to the DAG. ** Adds a new edge to the DAG by typing addedge ( ...) (creator), unless the edge already exists. Note that the bracketed creator is optional. See the prior explanation on node types to see what format nodes can be written in. If edgesAddNodes is enabled, new nodes will be created if they do not exist.
  • addnode - Creates and adds a new node to the DAG. ** Adds a new node to the DAG by typing addnode (creator), unless the node already exists. Note that the bracketed creator is optional. Node names may not start with [ '?()]. Node names may be surrounded by quotes "" to allow any characters. If an empty string is given "", an anonymous node is created, which is only assigned an ID and cannot be searched by name using the Node Alias Module.
  • addprop - Adds a named property to a node/edge using delimiters. ** Adds a property to a node/edge by typing _addprop N/E <node/edge> \n\n. Because properties could involve multiple lines, delimiters are used to properly capture the property. Any surrounding quotes in either the key or the property are stripped off.
  • batch - Provides a method for querying batches of input in a single command. ** Performs batches of the same command in a single call by typing batch \n\n\n...\n. The results are returned using the same delimiter to separate each command call.
  • count - Returns the count of another command's output. ** Simply returns the first argument (typically the count) of a command's output.
  • edge - Returns information about an edge by ID. ** Returns information about an edge by typing edge , which returns information about the edge in question.
  • findedges - Returns all edges that utilise the node arguments. ** Finds all edges utilising the given arguments (and optionally argument positions) by typing findedges (position) (position).... Note that the positions are 0-indexed. The bracketed position expressions do not need to be given if you don't care where the node is in the edge. The resulting edges are all edges that utilise the given nodes at the given positions. This can also cope with non-DAG nodes, such as primitives and strings but performance may suffer slightly.
  • findnodes - Finds all nodes by their name/alias. ** Finds all nodes of the given name by typing findnodes . Note that the latter two arguments are optional (default to true). The name may be quoted, though only the text inside the quote is used for searching. Case sensitive performs the search with/without case checking. Exact string searches for nodes with the exact name, or just start with the name.
  • getprop - Gets the value of a node/edge property. ** Get the value of a node/edge property by typing getprop N/E <node/edge> .
  • help - Provides help about a specified command. ** Provides a deeper explanation of the command. Probably not as deep as this document, but deeper than the short explanation.
  • intersect - Intersects the outputs of two or more commands. ** Finds the common elements of two sets of outputs, splitting the outputs by the '|' character.
  • list - Lists available commands. ** Brings up the list of possible commands (i.e. the commands here).
  • listprops - Lists all properties active on the node/edge. ** Lists the properties of a node/edge by typing listprops N/E <node/edge>. The output is "key"="property" on each line. This may get messy with multi-line properties.
  • map - Uses the outputs of one command as input to another. ** A functional command that takes the output of one command as the input of another, using regular expressions to parse the output syntax.
  • node - Returns information about a node by ID. ** Returns information about a node by typing node , which returns information about the node in question.
  • numedges - Returns the number of edges in the DAG. ** Returns the number of edges in the DAG. This is not necessarily the next ID value for an edge though.
  • numnodes - Returns the number of nodes in the DAG. ** Returns the number of nodes in the DAG. This is not necessarily the next ID value for a node though.
  • quit - Ends this session. ** Ends this local session (not the whole DAG though).
  • randomedge - Returns a random edge from the DAG.
  • randomnode - Returns a random node from the DAG.
  • removeedge - Removes an edge from the DAG. ** Removes an edge by typing removeedge .
  • removenode - Removes a specific node from the DAG. ** Removes a node by typing removenode . This also removes any edges associated with this node.
  • removeprop - Removes a property from the node/edge. ** Removes a node/edge property by typing removeprop N/E <node/edge> .
  • set - Set the value of a variable. ** Sets the value of a session variable to a given value. See vars for the active variables.
  • shutdown - Shuts down the entire DAG. ** Shuts the entire DAG down. This synchronises the data (see below) and closes all sessions accessing the DAG.
  • stats - Outputs a brief overview of various DAG statistics. ** Outputs the number of nodes & edges, the uptime of the DAG, and string representations of the current modules.
  • sync - Synchronises the DAG information to file. ** This synchronises the information in RAM with the physical files on the HD, such that future sessions can load this information and resume from where the last session ended.
  • union - Unions the outputs of two or more commands. ** Joins two sets of outputs, splitting the outputs by the '|' character.
  • vars - List variables. ** Lists the variables currently being used by the session (not the entire DAG). These include: *** /env/time If the time taken (in nanoseconds) to process a command should be shown. Defaults to 'true'. *** /env/pretty If the results of each command should output node names instead of node IDs. Defaults to 'false'. *** /env/edgesAddNodes If new nodes should be created if they do not exist when creating edges. Defaults to 'false'. *** /env/endmessage The delimiter used to indicate the command is complete. Defaults to '--message end--'. *** /env/singleline If the output should replace all newlines by ' '. Defaults to false. *** /env/prompt The prefix to show to prompt command entry. Defaults to '>'.'.
Clone this wiki locally