Learn R Programming

toaster (version 0.5.5)

validateGraph: Validate graph data in Aster for consistency.

Description

Aster uses the following pair of tables to store graph data: - vertices table with unique key and optional attributes - Edges table with source, target and optional attributes Also see toaGraph Graph validation checks for the following:
  • Both tables exist (error returned).
  • Edge sources exist in the vertices table.
  • Edge targets exist in the vertices table.
  • No duplicate vertices defined.
  • No duplicate edges defined.
  • No loops (self-directed edges) defined.

Usage

validateGraph(channel, graph, weight = NULL, vertexWhere = graph$vertexWhere, edgeWhere = graph$edgeWhere, allTables = NULL, test = FALSE)

Arguments

channel
connection object as returned by odbcConnect
graph
an object of class 'toagraph' referencing graph tables in Aster database.
weight
logical or character: if logical then TRUE indicates using 'weight' edge attribute, otherwise no weight used. If character then use as a name for the edge weight attribute. The edge weight may apply with types 'clustering', 'shortestpath' and centrality measures.
vertexWhere
SQL WHERE clause limiting data from the vertex table. This value when not null overrides corresponding value vertexWhere from graph (use SQL as if in WHERE clause but omit keyword WHERE).
edgeWhere
SQL WHERE clause limiting data from the edge table. This value when not null overrides corresponding value edgeWhere from graph (use SQL as if in WHERE clause but omit keyword WHERE).
allTables
pre-built information about existing tables.
test
logical: if TRUE show what would be done, only (similar to parameter test in RODBC functions: sqlQuery and sqlSave).

Examples

Run this code
if(interactive()) {

# initialize connection to Lahman baseball database in Aster 
conn = odbcDriverConnect(connection="driver={Aster ODBC Driver};
                         server=<dbhost>;port=2406;database=<dbname>;uid=<user>;pwd=<pw>")

# undirected graph
policeGraphUn = toaGraph(vertices="dallaspolice_officer_vertices", 
                         edges="dallaspolice_officer_edges_un", 
                         directed=FALSE, key="officer", 
                         source="officer1", target="officer2", 
                         vertexAttrnames = c("offense_count"),
                         edgeAttrnames = c("weight"))
validateGraph(conn, policeGraphUn)

# directed graph
policeGraphDi = toaGraph(edges="dallaspolice_officer_vertices", 
                         vertices="dallaspolice_officer_edges_di", 
                         directed=TRUE, key="officer", 
                         source="officer1", target="officer2", 
                         vertexAttrnames = c("offense_count"),
                         edgeAttrnames = c("weight"))
validateGraph(conn, policeGraphDi, weight=TRUE)

}

Run the code above in your browser using DataLab