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