computeGraph: Materialize Aster graph as network object in R.

Description Usage Arguments Details Value Examples

Description

Results in network object representation of the graph stored in Aster tables. Usually in Aster database a graph is represented using a pair of vertice and edge tables (see toaGraph).

Usage

1
2
computeGraph(channel, graph, v = 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.

v

a SQL SELECT that returns key values or a list of key values (corresponding to the vertex.names attribute) of the vertices to include in the graph. When not NULL this guarentees that no other vertices or edges between other vertices are included in the resulting network.

vertexWhere

optionally, a SQL WHERE clause to subset vertex table. When not NULL it overrides vertexWhere condition from the graph.

edgeWhere

optionally, a SQL WHERE clause to subset edge table. When not NULL it overrides edgeWhere condition from the graph.

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).

Details

Use caution when computing network objects stored in Aster with this function as data may include considerable amount of vertices and edges which are too large to load into a memory.

copmuteGraph will use graph defined by graph if neither of the arguments vertexWhere, or edgeWhere provided. When one or more of them defined then they override corresponding attributes in the graph. On top of it, argument v specifies concrete vertices to include in the resulting graph. In case when only edges table specified argument vertexWhere will trigger error while argument v is still valid.

Value

network class object materializing an Aster graph represented by toaGraph.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
if(interactive()) {
library(GGally)

policeGraphUn = toaGraph("dallaspolice_officer_vertices", "dallaspolice_officer_edges_un", 
                         directed = FALSE, key = "officer", 
                         source = "officer1", target = "officer2", 
                         vertexAttrnames = c("offense_count"), edgeAttrnames = c("weight"))
               
# 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>")
                             
# create network object and visualize with ggplot2
net1 = computeGraph(conn, policeGraphUn)
ggnet2(net1, node.label="vertex.names", node.size="offense_count", 
       legend.position="none")
       
# network object with filters and color attribute
net2 = computeGraph(conn, policeGraphUn, vertexWhere = "officer ~ '[A-Z].*'", 
                    edgeWhere = "weight > 0.36")
net2 %v% "color" = substr(get.vertex.attribute(net2, "vertex.names"), 1, 1)
ggnet2(net2, node.label="vertex.names", node.size="offense_count", 
       size.cut=TRUE, node.color="color", legend.position="none", 
       palette = "Set2")

# networ object for subgraph of top degree vertices
topDegree = computeGraphMetric(conn, policeGraphUn, type="degree", top=50)
net3 = computeGraph(conn, policeGraphUn, v=as.list(as.character(topDegree$key)))
net3 %v% "degree" = topDegree[match(get.vertex.attribute(net3, "vertex.names"), 
                                            topDegree$key), "degree"]
ggnet2(net3, node.label="vertex.names", node.size="degree", 
       legend.position="none")
                         
}

teradata-aster-field/toaster documentation built on May 31, 2019, 8:36 a.m.