toaGraph: Define an object corresponding to a graph in Aster database.

Description Usage Arguments Details Examples

View source: R/computeGraph.R

Description

In Aster Database, to process graphs using SQL-GR, it is recommended to represent a graph using two tables:

  1. Vertices table

  2. edges table

Vertices table must contain a unique key so that each row represents a vertex. Edges table must contain a pair of source and target keys (from vertices table) so that each row represents an edge. Both vertices and edges tables may contain additional columns representing optional attributes. For example if edges table has column 'weight' it can correspond a graph with edge weights.

Usage

1
2
3
toaGraph(vertices, edges, directed = FALSE, key = "id", source = "source",
  target = "target", vertexAttrnames = NULL, edgeAttrnames = NULL,
  vertexWhere = NULL, edgeWhere = NULL)

Arguments

vertices

A table, view, or query of a collection of vertices in the graph. The collection must contain at least one column representing the vertex key.

edges

A table, view, or query of a collection of edges of the graph. The collection must contain at least two columns, one list that represents the source vertex key and another list that represents the target vertex key.

directed

logical: should edges be interpreted as directed?

key

name of the column with vertex unique id (in the table vertices).

source

name of the column with the from vertex (in the table edges).

target

name of the column with the to vertex (in the tbale edges).

vertexAttrnames

optionally, a list of columns containing vertex attribute names.

edgeAttrnames

optionally, a list of columns containing edge attribute names.

vertexWhere

optionally, a SQL WHERE clause to subset vertex table (use SQL as if in WHERE clause but omit the keyword WHERE).

edgeWhere

optionally, a SQL WHERE clause to subset edge table (use SQL as if in WHERE clause but omit the keyword WHERE).

Details

Graph object can be defined using single table with edges. In that case vertices are derived from the edges and arguments vertexWhere and vertexAttrnames will be disallowed or ignored.

In place of both or any of the tables could be views or even queries. The only requirement is that they correspond to a graph in Aster database by containing non-null set of vertices, 0 or more edges and do not break referential integrity (see validateGraph). No speical syntactic designation is necessary when using queries, thus "public.edges" and "SELECT * FROM public.edges" are valid and equivalent values for the argument edges.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# undirected graph
policeGraphUn = toaGraph("dallaspolice_officer_vertices", "dallaspolice_officer_edges_un", 
     directed = FALSE, key = "officer", source = "officer1", target = "officer2", 
     vertexAttrnames = c("offense_count"), edgeAttrnames = c("weight"))
                         
# directed graph with the vertex filter
policeGraphDi = toaGraph("dallaspolice_officer_vertices", "dallaspolice_officer_edges_di", 
     directed = TRUE, key = "officer", source = "officer1", target = "officer2", 
     vertexAttrnames = c("offense_count"), edgeAttrnames = c("weight"),
     vertexWhere = "officer ~ '[A-Z].*'")
     

toaster documentation built on May 30, 2017, 3:51 a.m.