treeToDataFrames | R Documentation |
Converts a derivation tree into a list of two data frames.
With the R-package igraph
the data frames
can be plotted as a derivation tree.
treeToDataFrames(tree, G, verbose)
tree |
Derivation tree. |
G |
The context-free grammar. |
verbose |
If TRUE, print derivations on console. Default: FALSE. |
Works with complete and incomplete derivation trees.
A named list with two data frames:
The data frame $V
of vertices with the columns
$V$id
(numerical identifier) and $V$name
(symbol of the grammar G).
The data frame $E
of edges with the columns
$E$from
and $E$to$
.
g<-compileBNF(booleanGrammar())
a<-randomDerivationTree(g$Start, g)
x<-treeToDataFrames(a, g, verbose=TRUE)
# library(igraph)
# g1<-graph_from_data_frame(x$E, directed=TRUE, vertices=x$V)
# plot(g1, layout=layout_as_tree)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.