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>")
policeGraphUn = toaGraph("dallaspolice_officer_vertices", "dallaspolice_officer_edges_un",
directed = FALSE, key = "officer",
source = "officer1", target = "officer2",
vertexAttrnames = c("offense_count"), edgeAttrnames = c("weight"))
# visualize the whole graph
showGraph(conn, policeGraphUn, node.label = "vertex.names", node.size="offense_count")
# visualize subgraph using both vertex and edge filters
showGraph(conn, policeGraphUn,
vertexWhere = "officer ~ '[A-Z ].*'", edgeWhere = "weight > 0.10",
node.label = "vertex.names", node.size="offense_count")
}
Run the code above in your browser using DataLab