Description Usage Arguments Details Examples
In Aster Database, to process graphs using SQL-GR, it is recommended to represent a graph using two tables:
Vertices table
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.
1 2 3 |
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 |
source |
name of the column with the from vertex (in the table |
target |
name of the column with the to vertex (in the tbale |
vertexAttrnames |
optionally, a list of columns containing vertex attribute names. |
edgeAttrnames |
optionally, a list of columns containing edge attribute names. |
vertexWhere |
optionally, a |
edgeWhere |
optionally, a |
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
.
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].*'")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.