diff --git a/articles/graphviz-mermaid.html b/articles/graphviz-mermaid.html index dbd61497..63917b3c 100644 --- a/articles/graphviz-mermaid.html +++ b/articles/graphviz-mermaid.html @@ -195,8 +195,8 @@

Statements E->6 4->6 5->7 6->7 3->8 } ") -
- +
+

Subgraphs and Clusters @@ -398,8 +398,8 @@

Examples[1]: 'top' [2]: 10:20 ")

-
-

As can be seen from the output:

+
+

As can be seen from the output:

  1. the node with ID a is given the label “top” (after substituting @@1 with expression after the diff --git a/articles/selections.html b/articles/selections.html index 7c021964..44981264 100644 --- a/articles/selections.html +++ b/articles/selections.html @@ -588,8 +588,8 @@

    Selecting the Last Nod # View the new graph graph_2 %>% render_graph() -
    -

    The graph shows two nodes connected together. Nothing more, nothing +

    +

    The graph shows two nodes connected together. Nothing more, nothing less. The more interesting views of the data are of the node and edge data frames, which now have several attributes set. Let’s have a look at the graph’s internal node data frame…

    @@ -597,14 +597,14 @@

    Selecting the Last Nod # Inspect the new graph's NDF graph_2 %>% get_node_df() #> id type label timestamp -#> 1 1 A <NA> 2023-11-08 15:34:26.734465 -#> 2 2 B <NA> 2023-11-08 15:34:26.762557 +#> 1 1 A <NA> 2023-11-09 02:21:19.164171 +#> 2 2 B <NA> 2023-11-09 02:21:19.19189

    …and let’s inspect the graph’s internal edge data frame.

     # Inspect the new graph's EDF
     graph_2 %>% get_edge_df()
    -#>   id from to rel                  timestamp
    -#> 1  1    1  2  AB 2023-11-08 15:34:26.783747
    +#> id from to rel timestamp +#> 1 1 1 2 AB 2023-11-09 02:21:19.21292

    As can be seen, immediately invoking select_last_nodes_created() or select_last_edges_created() after addition of new nodes or diff --git a/articles/simple-graphs-ndfs-edfs.html b/articles/simple-graphs-ndfs-edfs.html index 8a057e7e..b0aa940c 100644 --- a/articles/simple-graphs-ndfs-edfs.html +++ b/articles/simple-graphs-ndfs-edfs.html @@ -281,8 +281,8 @@

    Viewing a Graph ObjectLet’s have a look at the graph created in the last example:

    -
    -

    If you’d like to return the Graphviz DOT code (to, perhaps, share it +

    +

    If you’d like to return the Graphviz DOT code (to, perhaps, share it or use it directly with the Graphviz command-line utility), we can use the generate_dot() function. Here’s a simple example:

    diff --git a/articles/traversals.html b/articles/traversals.html
    index 88414e15..faa6573b 100644
    --- a/articles/traversals.html
    +++ b/articles/traversals.html
    @@ -229,8 +229,8 @@ 

    Traversals Across Nodes ) graph_1 %>% render_graph()

    -
    -

    We can now take the selection (still the central node 1) +

    +

    We can now take the selection (still the central node 1) and traverse via outbound edges to adjacent nodes: 2, 3, 4, 5, and 6.

    @@ -317,8 +317,8 @@ 

    Traversals Across Nodes # View the created graph graph %>% render_graph()

    -
    -
    +
    +
     graph %>%
       select_nodes_by_id(nodes = 1) %>%
       trav_out() %>%
    @@ -352,8 +352,8 @@ 

    Traversals Across Nodes # View the updated graph updated_graph %>% render_graph()

    -
    -

    We are not limited to starting a traversal from a single node ID +

    +

    We are not limited to starting a traversal from a single node ID value. We can, for example, begin from a selection of nodes based on a regular expression and traverse to a matching type string value (or to other node attributes that have character @@ -399,8 +399,8 @@

    Traversals Across Nodes # View the graph graph %>% render_graph()

    -
    -
    +
    +
     # View the internal NDF for sake of
     # reference
     graph %>% get_node_df()
    @@ -624,8 +624,8 @@ 

    Traversals from Nodes to Edges) graph %>% render_graph()

    -
    - +
    +
    diff --git a/pkgdown.yml b/pkgdown.yml index 308dd858..87df3e72 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -7,5 +7,5 @@ articles: selections: selections.html simple-graphs-ndfs-edfs: simple-graphs-ndfs-edfs.html traversals: traversals.html -last_built: 2023-11-08T15:33Z +last_built: 2023-11-09T02:20Z diff --git a/reference/DiagrammeR-package.html b/reference/DiagrammeR-package.html index 124f7fc6..87f6e826 100644 --- a/reference/DiagrammeR-package.html +++ b/reference/DiagrammeR-package.html @@ -70,7 +70,8 @@

    See also

    Author

    Maintainer: Richard Iannone riannone@me.com (ORCID)

    - +

    Authors:

    diff --git a/reference/get_graph_log.html b/reference/get_graph_log.html index 44dd19ee..d449d538 100644 --- a/reference/get_graph_log.html +++ b/reference/get_graph_log.html @@ -101,10 +101,10 @@

    Examples#> # A tibble: 4 × 8 #> version_id function_used time_modified duration nodes edges d_n d_e #> <int> <chr> <dttm> <dbl> <int> <int> <int> <int> -#> 1 1 create_graph 2023-11-08 15:33:54 0.00279 0 0 0 0 -#> 2 2 add_gnm_graph 2023-11-08 15:33:54 0.0106 10 15 10 15 -#> 3 3 delete_node 2023-11-08 15:33:54 0.0139 9 11 -1 -4 -#> 4 4 delete_node 2023-11-08 15:33:54 0.0171 8 8 -1 -3 +#> 1 1 create_graph 2023-11-09 02:20:46 0.00300 0 0 0 0 +#> 2 2 add_gnm_graph 2023-11-09 02:20:46 0.0111 10 15 10 15 +#> 3 3 delete_node 2023-11-09 02:20:46 0.0146 9 11 -1 -4 +#> 4 4 delete_node 2023-11-09 02:20:46 0.0179 8 8 -1 -3 diff --git a/reference/get_graph_series_info.html b/reference/get_graph_series_info.html index e9d32b66..9ba9f563 100644 --- a/reference/get_graph_series_info.html +++ b/reference/get_graph_series_info.html @@ -107,9 +107,9 @@

    Examples# Get information on the graphs in the series series %>% get_graph_series_info() #> graph name date_time tz nodes edges directed -#> 1 1 graph_SVUyR63K 2023-11-08 15:33:55 UTC 4 3 TRUE -#> 2 2 graph_SueySz3B 2023-11-08 15:33:55 UTC 5 5 TRUE -#> 3 3 graph_HYG7a9jw 2023-11-08 15:33:55 UTC 6 5 TRUE +#> 1 1 graph_SVUyR63K 2023-11-09 02:20:47 UTC 4 3 TRUE +#> 2 2 graph_SueySz3B 2023-11-09 02:20:47 UTC 5 5 TRUE +#> 3 3 graph_HYG7a9jw 2023-11-09 02:20:47 UTC 6 5 TRUE diff --git a/reference/remove_graph_from_graph_series.html b/reference/remove_graph_from_graph_series.html index e2383c92..611d4d05 100644 --- a/reference/remove_graph_from_graph_series.html +++ b/reference/remove_graph_from_graph_series.html @@ -125,8 +125,8 @@

    Examplesseries %>% get_graph_series_info() #> graph name date_time tz nodes edges directed -#> 1 1 graph_mkRJxXyq 2023-11-08 15:34:06 UTC 4 3 TRUE -#> 2 2 graph_ySz3BP7j 2023-11-08 15:34:06 UTC 6 5 TRUE +#> 1 1 graph_mkRJxXyq 2023-11-09 02:20:58 UTC 4 3 TRUE +#> 2 2 graph_ySz3BP7j 2023-11-09 02:20:59 UTC 6 5 TRUE diff --git a/reference/to_igraph.html b/reference/to_igraph.html index 845fdc61..6dbb2fc1 100644 --- a/reference/to_igraph.html +++ b/reference/to_igraph.html @@ -106,7 +106,7 @@

    Examples# Get a summary of the igraph # graph object summary(ig_graph) -#> IGRAPH 267c86e DN-B 36 50 -- +#> IGRAPH 745e524 DN-B 36 50 -- #> + attr: name (v/c), type (v/c), label (v/c), rel (e/c) diff --git a/search.json b/search.json index 626f5073..6c21af99 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":[]},{"path":"/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement riannone@.com. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2014-2023 DiagrammeR authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"graphviz","dir":"Articles","previous_headings":"","what":"Graphviz","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz support integral part DiagrammeR package. Graphviz consists graph description language called DOT language also comprises various tools can process DOT language. DOT highly customizable allows control line colors, arrow shapes, node shapes, many layout features.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"diagrammer-implementation","dir":"Articles","previous_headings":"","what":"DiagrammeR Implementation","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz graphs, DiagrammeR uses processing function called grViz(). pass grViz() valid graph specification DOT language. DOT graph description can either delivered grViz() form string, reference Graphviz file (.gv file extension), text connection. code examples provided later sections call grViz() function R script pass graph description string. important consider strings R contain unescaped double-quote characters. However, grViz() function allows single-quote characters place. convenience, DOT graph description supplied file (e.g., dot-graph.gv) text connection, either format quotes accepted. recent builds RStudio, use external text file .gv file extension can provide advantage syntax coloring previewing RStudio Viewer pane saving ('Preview Save' selected), , pressing 'Preview' button Source pane.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"defining-a-graphviz-graph","dir":"Articles","previous_headings":"","what":"Defining a Graphviz Graph","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz graph specification must begin directive stating whether directed graph (digraph) undirected graph (graph) desired. Semantically, indicates whether natural direction one edge’s nodes . optional graph ID follows paired curly braces denotes body statement list (stmt_list). Optionally, graph may also described strict. forbids creation multi-edges (.e., can one edge given tail node head node directed case). undirected graphs, can one edge connected two nodes. Subsequent edge statements using two nodes identify edge previously defined one apply attributes given edge statement. basic structure:","code":"[strict] (graph | digraph) [ID] '{' stmt_list '}'"},{"path":"/articles/graphviz-mermaid.html","id":"statements","dir":"Articles","previous_headings":"","what":"Statements","title":"Graphviz and mermaid in DiagrammeR","text":"graph statement (graph_stmt), node statement (node_stmt), edge statement (edge_stmt) three commonly used statements Graphviz DOT language. Graph statements allow attributes set components graph. Node statements define provide attributes graph nodes. Edge statements specify edge operations nodes supply attributes edges. edge operations, directed graph must specify edge using edge operator -> undirected graph must use -- operator. Within statements follow statement lists. Thus node statement, list nodes expected. edge statement, list edge operations. list items can optionally attribute list (attr_list) modify attributes either node edge. Comments may placed within statement list. can marked using // /* */ structure. Comment lines denoted # character. Multiple statements within statement list can separated linebreaks ; characters multiple statements example nodes (case styled boxes circles) can easily defined along connections:","code":"grViz(\" digraph boxes_and_circles { # a 'graph' statement graph [overlap = true, fontsize = 10] # several 'node' statements node [shape = box, fontname = Helvetica] A; B; C; D; E; F node [shape = circle, fixedsize = true, width = 0.9] // sets as circles 1; 2; 3; 4; 5; 6; 7; 8 # several 'edge' statements A->1 B->2 B->3 B->4 C->A 1->D E->A 2->4 1->5 1->F E->6 4->6 5->7 6->7 3->8 } \")"},{"path":"/articles/graphviz-mermaid.html","id":"subgraphs-and-clusters","dir":"Articles","previous_headings":"","what":"Subgraphs and Clusters","title":"Graphviz and mermaid in DiagrammeR","text":"Subgraphs play three roles Graphviz. First, subgraph can used represent graph structure, indicating certain nodes edges grouped together. usual role subgraphs typically specifies semantic information graph components. can also provide convenient shorthand edges. edge statement allows subgraph left right sides edge operator. occurs, edge created every node left every node right. example, specification equivalent second role, subgraph can provide context setting attributes. example, subgraph specify blue default color nodes defined . context graph drawing, interesting example anonymous subgraph specifies nodes , B, C placed rank. third role subgraphs directly involves graph laid certain layout types. name subgraph begins cluster, Graphviz notes subgraph special cluster subgraph. supported, layout make nodes belonging cluster drawn together, entire drawing cluster contained within bounding rectangle.","code":"A -> {B C} A -> B A -> C subgraph { rank = same; A; B; C; }"},{"path":"/articles/graphviz-mermaid.html","id":"graphviz-attributes","dir":"Articles","previous_headings":"","what":"Graphviz Attributes","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz attributes allow style Graphviz graph. Combinations attributes nodes, edges, clusters, entire graph provide highly-customized layouts.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"node-attributes","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Node Attributes","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz attributes specified name-value pairs. Thus, set fillcolor node abc, one use lots node attributes. following provides visual guide notable ones.","code":"abc [fillcolor = red]"},{"path":"/articles/graphviz-mermaid.html","id":"edge-attributes","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Edge Attributes","title":"Graphviz and mermaid in DiagrammeR","text":"Edge attributes set way node attributes. example, set arrowhead style edge abc -> def, one use Quotation marks important multiword attributes, might used label attribute. Refer following important edge attributes","code":"abc -> def [arrowhead = diamond]"},{"path":"/articles/graphviz-mermaid.html","id":"colors","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Colors","title":"Graphviz and mermaid in DiagrammeR","text":"default, Graphviz can use colors provided hexadecimal values, , X11 color names. following provides entire list X11 color names. colors additional 4-color palettes based named color. additional colors can used appending digits 1-4 color name. Gray (grey) variations 0-100. Please note , color names, gray interchangeable grey.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"node-shapes","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Node Shapes","title":"Graphviz and mermaid in DiagrammeR","text":"’s shortage shapes available nodes. Nodes can changed default ellipse shape using shape parameter. table provides listing possible node shapes.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"arrow-shapes","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Arrow Shapes","title":"Graphviz and mermaid in DiagrammeR","text":"shapes arrows highly customizable. defining edge, arrowhead parameter allows change style arrowhead default normal arrow shape, one several others. arrowhead types used.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"graphviz-substitution","dir":"Articles","previous_headings":"","what":"Graphviz Substitution","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz substitution allows mixing R expressions Graphviz DOT graph specification without sacrificing readability.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"how-it-works","dir":"Articles","previous_headings":"Graphviz Substitution","what":"How It Works","title":"Graphviz and mermaid in DiagrammeR","text":"take advantage substitution rendering graph, simply use grViz() function Graphviz DOT code: notation @@ within GraphViz DOT graph specification indicate substitution take place. Corresponding R expressions (formal graph specification, styled footnotes) provide values substituted. grViz() function autodetect whether working Graphviz DOT graph specification contains @@s curly braces [graph|digraph] {...} DOT construction. specify substitution @@, must ensure valid expression substitution. expressions placed footnotes evaluations must result R vector object (.e., data frame, list, matrix). possibility multiple substitutions, numbering required. Thus, @@ notation immediately followed number number correspond number footnoted R expression. substitution construction : Importantly, footnote expressions reside closing curly brace graph digraph expression. always take form : simple example specifying single node, following substitution syntax used: example, [1]: footnote expression evaluates '', , ’s substituted place @@1 (resultant , turn, taken node ID). Substitutions can also used insert values vector indices graph specification. Simply use format: ’s example specific values vectors can inserted graph: evaluation footnote expressions substitution, graph specification becomes :","code":"grViz(\" [...graph spec with substitutions using @@ notation and footnote R expressions...] \") \"@@\" + [footnote number] \"[\" + [footnote number] + \"]:\" digraph { @@1 } [1]: 'a' \"@@\" + [footnote number] + \"-\" + [index number] digraph alpha { @@1-1; @@1-2; @@1-3; @@1-4; @@1-5 @@1-6; @@1-7; @@1-8; @@1-9; @@1-10 } [1]: LETTERS digraph alpha { A; B; C; D; E F; G; H; I; J }"},{"path":"/articles/graphviz-mermaid.html","id":"examples","dir":"Articles","previous_headings":"Graphviz Substitution","what":"Examples","title":"Graphviz and mermaid in DiagrammeR","text":"best way demonstrate substitution works set examples. example substituting alphabet letters R’s LETTERS constant Graphviz graph specification. can mix substitutions single-values objects specifying indices R vector objects. example: can seen output: node ID given label “top” (substituting @@1 expression [1]: footnote R expression) nodes ID values b j respectively provided values indices 1 9 (using hyphenated form @@) evaluated expression 10:20 ([2]: footnote expression) Footnote expressions meant flexible. can span multiple lines, can also take objects available global workspace. , long vector object results evaluation, substitution can performed.","code":"grViz(\" digraph a_nice_graph { # node definitions with substituted label text node [fontname = Helvetica] a [label = '@@1'] b [label = '@@2-1'] c [label = '@@2-2'] d [label = '@@2-3'] e [label = '@@2-4'] f [label = '@@2-5'] g [label = '@@2-6'] h [label = '@@2-7'] i [label = '@@2-8'] j [label = '@@2-9'] # edge definitions with the node IDs a -> {b c d e f g h i j} } [1]: 'top' [2]: 10:20 \")"},{"path":"/articles/node-edge-data-frames.html","id":"node-and-edge-data-frames","dir":"Articles","previous_headings":"","what":"Node and Edge Data Frames","title":"Node and Edge Data Frames","text":"functions used create manipulate specialized data frames: node data frames (NDFs) edge data frames (EDFs). functions useful one can selectively add field data data frames combine necessary addition graph object.","code":""},{"path":"/articles/node-edge-data-frames.html","id":"creating-an-ndf","dir":"Articles","previous_headings":"","what":"Creating an NDF","title":"Node and Edge Data Frames","text":"create_node_df() function, one can create node data frame (NDF) nodes attributes. object really just R data.frame object. cases, ’s recommended use create_node_df() instead data.frame() (, .data.frame()) create NDF. Using create_node_df() allows validation input data (integrity graph compromised) function provides additional functionality base R functions data frame creation : single values repeated n number nodes supplied selective setting attributes (e.g., giving attr values 3 10 nodes, allowing non-set nodes use defaults globally set attr values) supplying overlong vectors attributes result trimming number nodes setting label = FALSE conveniently result non-labeled node function one argument requires values supplied: nodes argument. Just supplying set unique ID values nodes create NDF nodes additional attributes. incorporated graph, NDF parsed column names match keywords node attributes indicate DiagrammeR values columns provide attribute values per-node basis. Columns names don’t match reserved attribute names disregarded , , can include columns useful data analysis. creating node data frame, one column named nodes created (first column NDF). ’s unique values node ID reside. attribute columns, type label columns also created. However, necessarily need populated values thus can left blank, desired. attributes voluntarily added named vectors R triple-dot (...) argument. node attribute names types values supply: color — provide X11 hexadecimal color (append 2 digits hex alpha) distortion — node distortion shape = polygon fillcolor — provide X11 hexadecimal color (append 2 digits hex alpha) fixedsize — true false fontcolor — provide X11 hexadecimal color (append 2 digits hex alpha) fontname — name font fontsize — size font node label height — height node penwidth — thickness stroke shape peripheries — number peripheries (essentially, additional shape outlines) shape — node shape (e.g., ellipse, polygon, circle, etc.) sides — shape = polygon, number sides can provided style — usually given value filled ’d like fill node color tooltip — provide text unstyled browser tooltip width — width node x — x position node (requires graph attr layout = neato use) y — y position node (requires graph attr layout = neato use) following examples, node data frames created. worthwhile things notice . nodes can supplied character vector (c(\"\", \"b\", \"c\", \"d\")), , range integers (1:4). may matter preference, numbering system seems better choice (functions available package take advantage graph ID values available monotonically increasing integer values). Secondly, single logical value can supplied label argument, TRUE copies node ID label attribute, FALSE yields blank, unset value nodes NDF. Finally, provision single values call creates single node result nodes attribute (e.g., color = \"aqua\" sets nodes NDF ‘aqua’ color).","code":"# Create a node data frame nodes_1 <- create_node_df( n = 4, type = \"lower\", label = c(\"a\", \"b\", \"c\", \"d\"), style = \"filled\", color = \"aqua\", shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), data = c(3.5, 2.6, 9.4, 2.7)) # Inspect the `nodes_1` NDF nodes_1 #> id type label style color shape data #> 1 1 lower a filled aqua circle 3.5 #> 2 2 lower b filled aqua circle 2.6 #> 3 3 lower c filled aqua rectangle 9.4 #> 4 4 lower d filled aqua rectangle 2.7 # Create another node data frame nodes_2 <- create_node_df( n = 4, type = \"upper\", label = TRUE, style = \"filled\", color = \"red\", shape = \"triangle\", data = c(0.5, 3.9, 3.7, 8.2)) # Inspect the `nodes_2` NDF nodes_2 #> id type label style color shape data #> 1 1 upper 1 filled red triangle 0.5 #> 2 2 upper 2 filled red triangle 3.9 #> 3 3 upper 3 filled red triangle 3.7 #> 4 4 upper 4 filled red triangle 8.2"},{"path":"/articles/node-edge-data-frames.html","id":"creating-an-edf","dir":"Articles","previous_headings":"","what":"Creating an EDF","title":"Node and Edge Data Frames","text":"Using create_edge_df() function, edge data frame (EDF) (comprising edges attributes) created. create_node_df() function, resulting object R data.frame object. usual means creating data frames used create EDF, create_edge_df() function provides conveniences validation final object (e.g., checking uniqueness supplied node ID values). Also, special attribute edge called rel, short relationship. optional attribute, , can left blank. However, ’s advantageous types group labels set edges, especially resulting graph fashioned property graph. (node type values must also set node model graph property graph.) Edges define connections nodes graph. , sense, edge data frame complementary component node data frame within graph. Therefore, EDF contains node ID information two columns named . , making edge data frame, two equal-length vectors need supplied create_edge_df() function: one outgoing node edge (), , another incoming node edge (). two columns contain node ID values. node data frame, attributes can provided edges. following edge attributes can used: arrowhead — arrow style head end (e.g, normal, dot) arrowsize — scaling factor arrowhead arrowtail arrowtail — arrow style tail end (e.g, normal, dot) color — stroke color; X11 color hex code (add 2 digits alpha) dir — direction; either forward, back, , none fontcolor — choose X11 color provide hex code (append 2 digits alpha) fontname — name font fontsize — size font node label headport — cardinal direction arrowhead meets node label — label text line nodes minlen — minimum rank distance head tail penwidth — thickness stroke arrow tailport — cardinal direction tail emitted node tooltip — provide text edge tooltip examples edge data frames can created:","code":"# Create an edge data frame edges_1 <- create_edge_df( from = c(1, 1, 2, 3), to = c(2, 4, 4, 1), rel = \"requires\", color = \"green\", data = c(2.7, 8.9, 2.6, 0.6)) edges_1 #> id from to rel color data #> 1 1 1 2 requires green 2.7 #> 2 2 1 4 requires green 8.9 #> 3 3 2 4 requires green 2.6 #> 4 4 3 1 requires green 0.6 # Create another edge data frame edges_2 <- create_edge_df( from = c(5, 7, 8, 8), to = c(8, 8, 6, 5), rel = \"receives\", arrowhead = \"dot\", color = \"red\") edges_2 #> id from to rel arrowhead color #> 1 1 5 8 receives dot red #> 2 2 7 8 receives dot red #> 3 3 8 6 receives dot red #> 4 4 8 5 receives dot red"},{"path":"/articles/node-edge-data-frames.html","id":"combining-ndfs","dir":"Articles","previous_headings":"","what":"Combining NDFs","title":"Node and Edge Data Frames","text":"Several node data frames (NDFs) can combined one using combine_ndfs() function. can combine two NDFs single call combine_ndfs(), , combine even single pass. may occasion combine several NDFs single node data frame. combine_ndfs() function works much like base R rbind() function except accepts NDFs columns differing number, names, ordering. Obtaining several node data frames may result collecting data various sources, different times (collected data different), , simply multiple calls create_node_df() practical readability purposes, name examples. Speaking examples:","code":"# Create an NDF nodes_1 <- create_node_df( n = 4, label = 1:4, type = \"lower\", data = c(8.2, 5.2, 1.2, 14.9)) # Create another NDF nodes_2 <- create_node_df( n = 4, label = 5:8, type = \"upper\", data = c(0.3, 6.3, 10.7, 1.2)) # Combine the NDFs all_nodes <- combine_ndfs(nodes_1, nodes_2) all_nodes #> id type label data #> 1 1 lower 1 8.2 #> 2 2 lower 2 5.2 #> 3 3 lower 3 1.2 #> 4 4 lower 4 14.9 #> 5 5 upper 5 0.3 #> 6 6 upper 6 6.3 #> 7 7 upper 7 10.7 #> 8 8 upper 8 1.2"},{"path":"/articles/node-edge-data-frames.html","id":"combining-edfs","dir":"Articles","previous_headings":"","what":"Combining EDFs","title":"Node and Edge Data Frames","text":"may cases one might take data one data frames create multiple edge data frames. One can combine multiple edge data frames (EDFs) combine_edfs() function. number EDFs can safely combined one call function. , advantageous use combining function purpose coalescing EDFs. single, combined EDF generated, much easier incorporate data DiagrammeR graph object.","code":"# Create an edge data frame edges_1 <- create_edge_df( from = c(1, 1, 2, 3), to = c(2, 4, 4, 1), rel = \"requires\", color = \"green\", data = c(2.7, 8.9, 2.6, 0.6)) # Create another edge data frame edges_2 <- create_edge_df( from = c(5, 7, 8, 8), to = c(8, 8, 6, 5), rel = \"receives\", arrowhead = \"dot\", color = \"red\") # Combine edge data frames with 'combine_edfs' all_edges <- combine_edfs(edges_1, edges_2) all_edges #> id from to rel color data arrowhead #> 1 1 1 2 requires green 2.7 #> 2 2 1 4 requires green 8.9 #> 3 3 2 4 requires green 2.6 #> 4 4 3 1 requires green 0.6 #> 5 5 5 8 receives red NA dot #> 6 6 7 8 receives red NA dot #> 7 7 8 6 receives red NA dot #> 8 8 8 5 receives red NA dot"},{"path":"/articles/selections.html","id":"creating-a-node-selection","dir":"Articles","previous_headings":"","what":"Creating a Node Selection","title":"Selections","text":"Selecting nodes graph accomplished targeting specific node attribute (e.g., type, label, styling attributes width, available, arbitrary data values available nodes). select_*() functions, graph argument first function signature. beneficial forward-piping graph pipeline propagating series transformations graph. may situations several types selections applied graphs nodes edges (say, selecting nodes graph first step subtracting nodes specific type group) pipeline paradigm becomes incredibly useful, , added bonus, easy read reason . main handle selectivity select_nodes() function node attributes graph’s internal NDF, contains columns possible node attributes graph. providing expression conditions, nodes placed active selection TRUE. two common types expressions work well conditions argument: logical expression comparison operator (>, <, ==, !=) regular expression filtering via string matching Let’s create simple graph four nodes numeric data values. , ’ll inspect graph’s internal NDF see starting . first example, nodes selected based logical expression operating collection numeric values. examine result selection, get_node_df_ws() used. function display table active selection nodes graph (like get_node_df(), subset nodes). selection nodes can obtained match using regular expression operating collection character-based values (node attribute named fruits). uses grepl() function expression supplied conditions. regular expression use ^ap, ^ denotes beginning text parsed. situation may arise specialized match needs made (.e., matching , , matching two different types things). set_op argument can become useful. selection nodes obtained using select_nodes() (select_*() functions operate nodes), selection stored graph object. seen examples get_selection() used verify nodes selection. selection retained (least clear_selection() called, , selection edges made), multiple uses select_nodes() can modify set selected nodes depending option provided set_op argument. set operations : union: creates union selected nodes consecutive operations create selection nodes (default option) intersect: modifies list selected nodes nodes common consecutive node selection operations retained difference: modifies list selected nodes nodes retained different second node selection operation compared first set operations behave exactly base R functions: union(), intersect()/intersection(), setdiff() (actually used internally). Furthermore, select_*() functions contain set_op argument, , behave way regard modifying node edge selection pipeline selection operations. examples important fully understanding can work complex selections, quite provided . example graph now bit complex. contain 9 nodes, three different types (fruit, veg, nut). label node attribute name food, count attribute contains arbitrary numeric values. Let’s successively use two select_nodes() calls select foods either begin c end e. set, use union set operation second call select_nodes(). conditions don’t need related. first , ’s matching expression using grepl(). second filtering nodes count < 5. following example contains pair select_nodes() statements, first filters nodes fruit group (type == \"fruit\") excludes subset nodes (fruit containing “apple” name) using set_op = \"difference\". additional filtering option available nodes argument. , vector node ID values can supplied indicate function subset nodes considered select_nodes(). Note , nothing provided conditions nodes given vector node ID values, nodes make selection function call. convenient often good method selecting nodes (long one knows node IDs need selected), function select_nodes_by_id() handles use case directly (filters based nodes argument). Let’s now perform call select_nodes() contains expression conditions argument, , range node ID values nodes argument.","code":"# Create a node data frame ndf <- create_node_df( n = 4, data = c( 9.7, 8.5, 2.2, 6.0) ) # Create a new graph based on the ndf graph <- create_graph(nodes_df = ndf) # Inspect the graph's NDF graph %>% get_node_df() #> id type label data #> 1 1 9.7 #> 2 2 8.5 #> 3 3 2.2 #> 4 4 6.0 # Select nodes where the `data` attribute # has a value greater than 7.0 (it's the # first 2 nodes) graph <- graph %>% select_nodes( conditions = data > 7.0 ) # Get the graph's current selection # of nodes as a table graph %>% get_node_df_ws() #> id type label data #> 1 1 9.7 #> 2 2 8.5 # Create a node data frame ndf <- create_node_df( n = 4, fruits = c( \"apples\", \"apricots\", \"bananas\", \"plums\") ) # Create a new graph based on the ndf graph <- create_graph(nodes_df = ndf) # Select nodes where the `fruits` # attribute has a match on the first # letters being `ap` (the first 2 nodes) graph <- graph %>% select_nodes( conditions = grepl(\"^ap\", fruits) ) # Get the graph's current selection # of nodes as a table graph %>% get_node_df_ws() #> id type label fruits #> 1 1 apples #> 2 2 apricots # Create a node data frame ndf <- create_node_df( n = 9, type = c( \"fruit\", \"fruit\", \"fruit\", \"veg\", \"veg\", \"veg\", \"nut\", \"nut\", \"nut\"), label = c( \"pineapple\", \"apple\", \"apricot\", \"cucumber\", \"celery\", \"endive\", \"hazelnut\", \"almond\", \"chestnut\"), count = c( 6, 3, 8, 7, 2, 6, 9, 9, 7) ) # Create a new graph based on the ndf graph <- create_graph(nodes_df = ndf) # Inspect the graph's NDF graph %>% get_node_df() #> id type label count #> 1 1 fruit pineapple 6 #> 2 2 fruit apple 3 #> 3 3 fruit apricot 8 #> 4 4 veg cucumber 7 #> 5 5 veg celery 2 #> 6 6 veg endive 6 #> 7 7 nut hazelnut 9 #> 8 8 nut almond 9 #> 9 9 nut chestnut 7 # Select all foods that either begin # with `c` or ending with `e` graph_1 <- graph %>% select_nodes( conditions = grepl(\"^c\", label) ) %>% select_nodes( conditions = grepl(\"e$\", label), set_op = \"union\" ) # Get the graph's current selection # of nodes as a table graph_1 %>% get_node_df_ws() #> id type label count #> 1 1 fruit pineapple 6 #> 2 2 fruit apple 3 #> 3 4 veg cucumber 7 #> 4 5 veg celery 2 #> 5 6 veg endive 6 #> 6 9 nut chestnut 7 # Select any food beginning with `a` and # having a count less than 5 graph_2 <- graph %>% select_nodes( conditions = grepl(\"^a\", label) ) %>% select_nodes( conditions = count < 5, set_op = \"intersect\" ) # Get the graph's current selection # of nodes as a table graph_2 %>% get_node_df_ws() #> id type label count #> 1 2 fruit apple 3 # Select any fruit not containing # `apple` in its name graph_3 <- graph %>% select_nodes( conditions = type == \"fruit\" ) %>% select_nodes( conditions = grepl(\"apple\", label), set_op = \"difference\" ) # Get the graph's current selection # of nodes as a table graph_3 %>% get_node_df_ws() #> id type label count #> 1 3 fruit apricot 8 # Create a node data frame ndf <- create_node_df( n = 10, data = seq(0.5, 5, 0.5) ) # Create a new graph based on the ndf graph <- create_graph(nodes_df = ndf) # Inspect the graph's NDF graph %>% get_node_df() #> id type label data #> 1 1 0.5 #> 2 2 1.0 #> 3 3 1.5 #> 4 4 2.0 #> 5 5 2.5 #> 6 6 3.0 #> 7 7 3.5 #> 8 8 4.0 #> 9 9 4.5 #> 10 10 5.0 # Select from a subset of nodes # (given as `nodes = 1:6`) where # the `data` value is greater than `1.5` graph <- graph %>% select_nodes( conditions = data > 1.5, nodes = 1:6 ) # Get the graph's current selection # of nodes as a table graph %>% get_node_df_ws() #> id type label data #> 1 4 2.0 #> 2 5 2.5 #> 3 6 3.0"},{"path":"/articles/selections.html","id":"creating-an-edge-selection","dir":"Articles","previous_headings":"","what":"Creating an Edge Selection","title":"Selections","text":"Selecting edges graph done manner quite similar selecting nodes. primary means targeting specific edges available edge attributes (e.g., rel, styling attributes color, arbitrary data values available edges). start creating graph four nodes four edges. edges edge attribute called data contains numeric values. following example shows create selections edges based logical expression operating collection numeric values data attribute.","code":"# Create a node data frame ndf <- create_node_df(n = 4) # Create an edge data frame edf <- create_edge_df( from = c(1, 2, 3, 4), to = c(2, 3, 4, 1), data = c( 8.6, 2.8, 6.3, 4.5) ) # Create a new graph from # the NDF and EDF graph <- create_graph( nodes_df = ndf, edges_df = edf ) # Inspect the graph's EDF graph %>% get_edge_df() #> id from to rel data #> 1 1 1 2 8.6 #> 2 2 2 3 2.8 #> 3 3 3 4 6.3 #> 4 4 4 1 4.5 # Select edges where the `data` # attribute has a value # greater than 5.0 graph <- graph %>% select_edges( conditions = data > 5.0 ) # Get the graph's current selection # of edges as a table graph %>% get_edge_df_ws() #> id from to rel data #> 1 1 1 2 8.6 #> 2 3 3 4 6.3"},{"path":"/articles/selections.html","id":"selecting-the-last-node-or-edge-in-an-ndf-or-edf","dir":"Articles","previous_headings":"","what":"Selecting the Last Node or Edge in an NDF or EDF","title":"Selections","text":"can select last node edge graph’s internal node data frame (NDF) internal edge data frame (EDF), respectively. Usually, last node edge created since new nodes edges added bottom data frame shuffling positions. Immediately creating single node edge, calling either select_last_node() select_last_edge() functions result selection last node edge created. functions, graph argument. provide graph object select_last_nodes_created() get active selection nodes (last nodes added graph object). Likewise, select_last_edges_created() create active selection edges, whichever edges last defined function call. begin, ’ll use graph ’ll clear active selection using clear_selection() function. ensure active selection nodes edges, can use get_selection() function. value NA means neither selection nodes edges. use select_last_nodes_created graph, find active selection nodes contains nodes graph, produced create_graph() function (nodes added subsequent operations). goes edges. Using select_last_edges_created() make selection edges includes edges graph. functions become useful building graph multiple steps. next example, start empty graph (using create_graph() ) add single node add_node(), select node select_last_nodes_created(). selection---pipeline approach makes easy set node attributes can use set_node_attrs_ws() function. example, ’re adding new timestamp attribute assigning value (system time). selection persistent, can set attributes calls set_node_attrs_ws(). done node selection, call clear_selection() function return clean slate active selection present (removes node edge selection graph object). example proceeds create another new node adding attributes, new edge edge attributes (set_edge_attrs_ws()). facilitated select_last_nodes_created() select_last_edges_created() functions. graph shows two nodes connected together. Nothing , nothing less. interesting views data node edge data frames, now several attributes set. Let’s look graph’s internal node data frame… …let’s inspect graph’s internal edge data frame. can seen, immediately invoking select_last_nodes_created() select_last_edges_created() addition new nodes edges can useful working newly made nodes/edges. Many functions ending _ws() operate specifically selections nodes edges.","code":"# Clear the graph's selection graph <- graph %>% clear_selection() # Check whether there is still # a selection present graph %>% get_selection() #> [1] NA # Select the last node in the graph's NDF and confirm # that the selection was made graph %>% select_last_nodes_created() %>% get_node_df_ws() #> id type label #> 1 1 #> 2 2 #> 3 3 #> 4 4 # Select the last edge in the graph's EDF and confirm # that the selection was made graph %>% select_last_edges_created() %>% get_edge_df_ws() #> id from to rel data #> 1 1 1 2 8.6 #> 2 2 2 3 2.8 #> 3 3 3 4 6.3 #> 4 4 4 1 4.5 # Create a graph, node-by-node and # edge-by-edge and add attributes graph_2 <- create_graph() %>% add_node() %>% select_last_nodes_created() %>% set_node_attrs_ws( node_attr = \"timestamp\", value = as.character(Sys.time()) ) %>% set_node_attrs_ws( node_attr = \"type\", value = \"A\" ) %>% clear_selection() %>% add_node() %>% select_last_nodes_created() %>% set_node_attrs_ws( node_attr = \"timestamp\", value = as.character(Sys.time()) ) %>% set_node_attrs_ws( node_attr = \"type\", value = \"B\" ) %>% add_edge( from = 1, to = 2, rel = \"AB\" ) %>% select_last_edges_created() %>% set_edge_attrs_ws( edge_attr = \"timestamp\", value = as.character(Sys.time()) ) %>% clear_selection() # View the new graph graph_2 %>% render_graph() # Inspect the new graph's NDF graph_2 %>% get_node_df() #> id type label timestamp #> 1 1 A 2023-11-08 15:34:26.734465 #> 2 2 B 2023-11-08 15:34:26.762557 # Inspect the new graph's EDF graph_2 %>% get_edge_df() #> id from to rel timestamp #> 1 1 1 2 AB 2023-11-08 15:34:26.783747"},{"path":"/articles/simple-graphs-ndfs-edfs.html","id":"creating-a-graph-object","dir":"Articles","previous_headings":"","what":"Creating a Graph Object","title":"Creating Simple Graphs from NDFs/EDFs","text":"create_graph() function creates graph object. function also allows initialization graph name, setting node_df edge_df, graph theme. key options create_graph() function : nodes_df — optional data frame graph’s nodes (vertices) attributes edges_df — optional data frame edges nodes/vertices attributes directed — required logical value stating whether graph considered directed graph (TRUE, default) undirected graph (FALSE) graph_name — optional character vector name graph nodes_df edges_df arguments, one can supply node data frame edge data frame, respectively. dgr_graph object can initialized without nodes edges (supplying NDF EDF function call), favorable option supplying nodes edges using functions modify existing graph. example whereby empty graph (initialized directed graph) created. Note graph’s internal nodes_df edges_df data frames empty , signifying empty graph. ’s possible include NDF EDF calling create_graph(). get edgeless graph (graph nodes edges nodes. edges can always defined later (functions add_edge(), add_edge_df(), add_edges_from_table(), etc., functions covered subsequent section). Quite often, cases node edge attributes applied nodes edges graph. achieve , ’s need create columns NDFs EDFs attributes (repeat attribute values rows columns). Default graph attributes can provided graph graph_attrs, node_attrs, edge_attrs arguments. supply attributes, use vectors graph, node, edge attributes. want graph directed graph, value directed argument set TRUE (default value). Choose FALSE undirected graph. next example include nodes edges contained within graph object. case, values type rel attributes nodes edges, respectively, provided. Adding values attributes optional important data modeling work.","code":"# Create the graph object graph <- create_graph() # Get the class of the object class(graph) #> [1] \"dgr_graph\" # It's an empty graph, so the NDF has no rows get_node_df(graph) #> [1] id type label #> <0 rows> (or 0-length row.names) # The EDF doesn't have any rows either get_edge_df(graph) #> [1] id from to rel #> <0 rows> (or 0-length row.names) # By default, the graph is considered directed is_graph_directed(graph) #> [1] TRUE # Create a node data frame ndf <- create_node_df( n = 4, label = 1:4, type = \"lower\", style = \"filled\", color = \"aqua\", shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), data = c(3.5, 2.6, 9.4, 2.7) ) # Inspect the NDF ndf #> id type label style color shape data #> 1 1 lower 1 filled aqua circle 3.5 #> 2 2 lower 2 filled aqua circle 2.6 #> 3 3 lower 3 filled aqua rectangle 9.4 #> 4 4 lower 4 filled aqua rectangle 2.7 # Create the graph and include the # `nodes` NDF graph <- create_graph(nodes_df = ndf) # Examine the NDF within the graph object get_node_df(graph) #> id type label style color shape data #> 1 1 lower 1 filled aqua circle 3.5 #> 2 2 lower 2 filled aqua circle 2.6 #> 3 3 lower 3 filled aqua rectangle 9.4 #> 4 4 lower 4 filled aqua rectangle 2.7 # Check if it's the same NDF (both externally # and internally) all(ndf == graph %>% get_node_df()) #> [1] TRUE ### # Create a graph with both nodes and edges # defined, and, add some default attributes # for nodes and edges ### # Create a node data frame ndf <- create_node_df( n = 4, label = c(\"a\", \"b\", \"c\", \"d\"), type = \"lower\", style = \"filled\", color = \"aqua\", shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), data = c(3.5, 2.6, 9.4, 2.7) ) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\" ) graph <- create_graph( nodes_df = ndf, edges_df = edf ) %>% set_node_attrs( node_attr = \"fontname\", values = \"Helvetica\" ) %>% set_edge_attrs( edge_attr = \"color\", values = \"blue\" ) %>% set_edge_attrs( edge_attr = \"arrowsize\", values = 2 ) # Examine the NDF within the graph object get_node_df(graph) #> id type label style color shape data fontname #> 1 1 lower a filled aqua circle 3.5 Helvetica #> 2 2 lower b filled aqua circle 2.6 Helvetica #> 3 3 lower c filled aqua rectangle 9.4 Helvetica #> 4 4 lower d filled aqua rectangle 2.7 Helvetica # Have a look at the graph's EDF get_edge_df(graph) #> id from to rel color arrowsize #> 1 1 1 4 leading_to blue 2 #> 2 2 2 3 leading_to blue 2 #> 3 3 3 1 leading_to blue 2"},{"path":"/articles/simple-graphs-ndfs-edfs.html","id":"viewing-a-graph-object","dir":"Articles","previous_headings":"","what":"Viewing a Graph Object","title":"Creating Simple Graphs from NDFs/EDFs","text":"render_graph() function, ’s possible view graph object, , output DOT code current state graph. Let’s look graph created last example: ’d like return Graphviz DOT code (, perhaps, share use directly Graphviz command-line utility), can use generate_dot() function. ’s simple example:","code":"graph %>% render_graph() # Take the graph object and generate a character # vector with Graphviz DOT code (using cat() for # a better appearance) graph %>% generate_dot() %>% cat() #> digraph { #> #> graph [layout = 'neato', #> outputorder = 'edgesfirst', #> bgcolor = 'white'] #> #> node [fontname = 'Helvetica', #> fontsize = '10', #> shape = 'circle', #> fixedsize = 'true', #> width = '0.5', #> style = 'filled', #> fillcolor = 'aliceblue', #> color = 'gray70', #> fontcolor = 'gray50'] #> #> edge [fontname = 'Helvetica', #> fontsize = '8', #> len = '1.5', #> color = 'gray80', #> arrowsize = '0.5'] #> #> '1' [label = 'a', style = 'filled', color = 'aqua', shape = 'circle', fontname = 'Helvetica'] #> '2' [label = 'b', style = 'filled', color = 'aqua', shape = 'circle', fontname = 'Helvetica'] #> '3' [label = 'c', style = 'filled', color = 'aqua', shape = 'rectangle', fontname = 'Helvetica'] #> '4' [label = 'd', style = 'filled', color = 'aqua', shape = 'rectangle', fontname = 'Helvetica'] #> '1'->'4' [color = 'blue', arrowsize = '2'] #> '2'->'3' [color = 'blue', arrowsize = '2'] #> '3'->'1' [color = 'blue', arrowsize = '2'] #> }"},{"path":"/articles/traversals.html","id":"traversals-across-nodes","dir":"Articles","previous_headings":"","what":"Traversals Across Nodes","title":"Traversals","text":"traverse across connected nodes without regard properties edges nodes, three functions available: trav_out(), trav_in(), trav_both(). types traversals always require initial selection one nodes, , traversing, selection one nodes returned. Directionality traversal key differentiator three functions. trav_out() function allows traversals connected nodes outbound nodes relation origin nodes (directed graph). trav_in() function, movement reversed: traversals towards connected nodes inbound nodes. example, take edge described 1->2 origin node node ID 1; trav_out() function change node selection node 1 node 2 nodes adjacent edge leads origin node outbound node. node 1 outbound edges nodes (e.g., 1->{2,3,4}) nodes connected outbound edges origin node part new selection. Take another example central node selected node, node outbound inbound edges adjacent nodes: {2,3,4}->1->{5,6,7}. function trav_in() used, nodes 2, 3, 4 become selected nodes; using trav_out() result nodes 5, 6, 7 becoming selected nodes. several examples traversals across nodes. Let’s perform two types traversals single node using trav_out() trav_in(). First, ’ll create simple graph two nodes edge (1 -> 2). Starting node 1 (initial selection), traverse node 2. traversal can occur, selection altered. demonstrate, let’s use similar set steps graph opposite edge direction. type traversal can’t alter selection outbound edges node 1, just inbound edge (2 -> 1). make traversal possible, need use trav_in() function instead. Multiple traversals can made single set statements. Let’s create path graph containing five nodes add_path() function. obtain graph form: 1->2->3->4->5 can easily create initial selection node 1 select_nodes_by_id() function. several calls trav_out() succession, can move selection node 1 node 5. Traversals commonly performed initial selection contains multiple nodes (usually, nodes something common ). Let’s look slightly complex graph multiple nodes initial selection can migrated final selection traversal. can now take selection (still central node 1) traverse via outbound edges adjacent nodes: 2, 3, 4, 5, 6. Alternatively, initial selection 1 can traverse via inbound edges adjacent nodes (trav_in()) expect different final selection nodes (7, 8, 9, 10, 11). trav_both() function results traversals adjacent nodes regardless edge directions nodes. , sense, direction movement adjacent nodes , , . example {2,3,4}->1->{5,6,7}, node 1 node selection, nodes 2 node 6 part new selection calling trav_both(). far, functions described modifying selections nodes based solely node adjacency direction edges adjacent nodes. Indeed without supplying values function, traversals occur without regard attributes nodes traversed . However, arguments node_attr match available filtering traversals satisfy logical statements numeric attributes matches character attributes. property graph, values available nodes’ type attribute edges’ rel attribute, traversal trav_out() , example, performed outbound, adjacent nodes specific type label. done setting node_attr = type providing value type match argument. limited starting traversal single node ID value. can, example, begin selection nodes based regular expression traverse matching type string value (node attributes character values). following example uses random graph food entities arbitrary edges . Traversing node node trav_out(), trav_in(), trav_both() can result specific targeting nodes. seen, traversal occurred, new selection can used obtain data nodes, , modify graph (adding new nodes selection). Especially used within pipeline, selection nodes, traversals, resulting actions quite readable.","code":"pre <- create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 1, to = 2) %>% select_nodes_by_id(nodes = 1) # Create a simple graph, create a single- # node selection and traverse to the other # node; obtain the final selection create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 1, to = 2) %>% select_nodes_by_id(nodes = 1) %>% trav_out() %>% get_selection() #> [1] 2 # Create a simple graph, create a single- # node selection and then attempt to traverse # to the other node; obtain the final selection create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 2, to = 1) %>% select_nodes_by_id(nodes = 1) %>% trav_out() %>% get_selection() #> [1] 1 # A traversal can occur if `trav_in()` is used # instead of `trav_out()` create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 2, to = 1) %>% select_nodes_by_id(nodes = 1) %>% trav_in() %>% get_selection() #> [1] 2 # Traverse across a path graph one # step at a time with `trav_out()` create_graph() %>% add_path(n = 5) %>% select_nodes_by_id(nodes = 1) %>% trav_out() %>% trav_out() %>% trav_out() %>% trav_out() %>% get_selection() #> [1] 5 graph_1 <- create_graph() %>% add_node() %>% select_nodes_by_id(nodes = 1) %>% add_n_nodes_ws( n = 5, direction = \"from\" ) %>% add_n_nodes_ws( n = 5, direction = \"to\" ) graph_1 %>% render_graph() graph_1 %>% trav_out() %>% get_selection() #> [1] 2 3 4 5 6 graph_1 %>% trav_in() %>% get_selection() #> [1] 7 8 9 10 11 # Create the graph described in the paragraph # above ({`2...4`} -> `1` -> {`5...7`}), # start from node `1` (as a selection), # traverse to all other adjacent nodes and # then obtain the current selection create_graph() %>% add_node() %>% select_nodes_by_id(nodes = 1) %>% add_n_nodes_ws( n = 3, direction = \"to\" ) %>% add_n_nodes_ws( n = 3, direction = \"from\" ) %>% trav_both() %>% get_selection() #> [1] 2 3 4 5 6 7 # Create a common graph with nodes having # various `type` values; set to render # always using `visNetwork` when calling # `render_graph()` graph <- create_graph() %>% add_node(type = \"type_a\") %>% add_n_nodes( n = 4, type = \"type_b\" ) %>% add_edge(from = 1, to = 2) %>% add_edge(from = 1, to = 3) %>% add_edge(from = 4, to = 1) %>% add_edge(from = 5, to = 1) %>% add_n_nodes( n = 4, type = \"type_c\" ) %>% add_edge(from = 1, to = 6) %>% add_edge(from = 1, to = 7) %>% add_edge(from = 8, to = 1) %>% add_edge(from = 9, to = 1) # View the created graph graph %>% render_graph() graph %>% select_nodes_by_id(nodes = 1) %>% trav_out() %>% get_selection() #> [1] 2 3 6 7 graph %>% select_nodes_by_id(nodes = 1) %>% trav_out(conditions = type == \"type_b\") %>% get_selection() #> [1] 2 3 graph %>% select_nodes_by_id(nodes = 1) %>% trav_out(conditions = type == \"type_c\") %>% get_selection() #> [1] 6 7 # Once the nodes have been selected via # a traversal, a useful thing to do would # be to attach new nodes to that selection updated_graph <- graph %>% select_nodes_by_id(nodes = 1) %>% trav_out(conditions = type == \"type_c\") %>% add_n_nodes_ws( n = 1, direction = \"from\", type = \"type_d\" ) # View the updated graph updated_graph %>% render_graph() # Create a graph with fruit, vegetables, # and nuts ndf <- create_node_df( n = 9, type = c( \"fruit\", \"fruit\", \"fruit\", \"veg\", \"veg\", \"veg\", \"nut\", \"nut\", \"nut\" ), label = c( \"pineapple\", \"apple\", \"apricot\", \"cucumber\", \"celery\", \"endive\", \"hazelnut\", \"almond\", \"chestnut\" ) ) edf <- create_edge_df( from = c( 9, 3, 6, 2, 6, 2, 8, 2, 5, 5 ), to = c( 1, 1, 4, 3, 7, 8, 1, 5, 3, 6 ) ) graph <- create_graph( nodes_df = ndf, edges_df = edf ) # View the graph graph %>% render_graph() # View the internal NDF for sake of # reference graph %>% get_node_df() #> id type label #> 1 1 fruit pineapple #> 2 2 fruit apple #> 3 3 fruit apricot #> 4 4 veg cucumber #> 5 5 veg celery #> 6 6 veg endive #> 7 7 nut hazelnut #> 8 8 nut almond #> 9 9 nut chestnut # Select all nodes with a label beginning # with `a` and traverse outward to all nodes graph %>% select_nodes( conditions = grepl(\"^a\", label) ) %>% trav_out() %>% get_selection() #> [1] 1 3 5 8 # This traversal results in a rather large # selection of nodes: `3` (`apricot`), `8` # (`almond`), `5` (`celery`), and `1` # (`pineapple`) # Now, select all nodes with a label beginning # with `c` (in this case, the `cucumber` and # `chestnut` and then traverse outward to any # node of the `fruit` type graph %>% select_nodes( conditions = grepl(\"^c\", label) ) %>% trav_out( conditions = type == \"fruit\" ) %>% get_selection() #> [1] 1 3 # The traversal has resulted in a selection of # nodes `3` (`apricot`) and `1` (`pineapple`)"},{"path":"/articles/traversals.html","id":"traversals-from-nodes-to-edges","dir":"Articles","previous_headings":"","what":"Traversals from Nodes to Edges","title":"Traversals","text":"Moving across nodes using traversal functions quite powerful thing . However, especially information-rich graphs, useful data can exist graph’s edges. reason, can traverse nodes onto adjacent edges. node--node traversal functions, direction edge important key distinction functions trav_out_edge() trav_in_edge(). types traversals always begin nodes (thus require initial selection one nodes) typically end selection one edges. traversal can made, initial selection nodes retained. Starting trav_out_edge() function, suppose selection single node 1 simple graph 1->2. Calling trav_out_edge() function simplest form (without values supplied except graph ) result edge selection edge 1->2 edge. Thus, traversal one nodes onto adjacent, outward edges. graph, selection, calling trav_in_edge() function result traversal (initial node selection node 1 retained, though nothing happened). trav_in_edge() function performs converse traversal, traversal one nodes onto adjacent, inward edges. Put another way, trav_in_edge() change selection edges point toward initially-selected node(s), . node--node traversal functions, traversals much powerful used matching conditions increase selectivity. certain edges may traversed (selected) important, especially cases traversal continues onto nodes (next section). Examples aid understanding functions. introduce conditions traversal, can use conditions argument. node--node traversal functions, optional values induce filtering node--edge traversals. graph fashioned property graph values set node type edge rel attributes, traversals trav_out_edge() trav_in_edge() restricted selection edges specific rel label.","code":"# Create a simple graph with two nodes, an # edge between them (`1` -> `2`); starting # from node `1` (as a selection), traverse # to the edge and then obtain the current # selection create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 1, to = 2) %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge() %>% get_selection() #> [1] 1 # If no traversal can occur the selection is # not altered. To demonstrate, use a similar # pipeline but reverse the edge direction create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 2, to = 1) %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge() %>% get_selection() #> [1] 1 # A traversal can occur if `trav_in_edge()` # is used instead of `trav_out_edge()` create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 2, to = 1) %>% select_nodes_by_id(nodes = 1) %>% trav_in_edge() %>% get_selection() #> [1] 1 # A selection of multiple edges can occur # as a result of a traversal create_graph() %>% add_node() %>% select_nodes_by_id(nodes = 1) %>% add_n_nodes_ws( n = 10, direction = \"from\" ) %>% add_n_nodes_ws( n = 10, direction = \"to\" ) %>% trav_out_edge() %>% get_selection() #> [1] 1 2 3 4 5 6 7 8 9 10 create_graph() %>% add_node() %>% select_nodes_by_id(nodes = 1) %>% add_n_nodes_ws( n = 10, direction = \"from\" ) %>% add_n_nodes_ws( n = 10, direction = \"to\" ) %>% trav_in_edge() %>% get_selection() #> [1] 11 12 13 14 15 16 17 18 19 20 # First, set a seed so the example # is reproducible suppressWarnings(RNGversion(\"3.5.0\")) set.seed(20) # Create a graph with fruit, # vegetables, nuts, and... people! ndf <- create_node_df( n = 14, type = c( \"person\", \"person\", \"person\", \"person\", \"person\", \"fruit\", \"fruit\", \"fruit\", \"veg\", \"veg\", \"veg\", \"nut\", \"nut\", \"nut\" ), label = c( \"Annie\", \"Donna\", \"Justine\", \"Ed\", \"Graham\", \"pineapple\", \"apple\", \"apricot\", \"cucumber\", \"celery\", \"endive\", \"hazelnut\", \"almond\", \"chestnut\" ) ) edf <- create_edge_df( from = sort( as.vector(replicate(5, 1:5)) ), to = as.vector( replicate(5, sample(6:14, 5)) ), rel = as.vector( replicate( 5, sample( c( \"likes\", \"dislikes\", \"allergic_to\" ), 5, TRUE, c(0.5, 0.25, 0.25) ) ) ) ) graph <- create_graph( nodes_df = ndf, edges_df = edf ) graph %>% render_graph()"},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Richard Iannone. Author, maintainer. Olivier Roy. Author.","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Iannone R, Roy O (2023). DiagrammeR: Graph/Network Visualization. R package version 1.0.10.9000, https://github.com/rich-iannone/DiagrammeR, https://rich-iannone.github.io/DiagrammeR/.","code":"@Manual{, title = {DiagrammeR: Graph/Network Visualization}, author = {Richard Iannone and Olivier Roy}, year = {2023}, note = {R package version 1.0.10.9000, https://github.com/rich-iannone/DiagrammeR}, url = {https://rich-iannone.github.io/DiagrammeR/}, }"},{"path":"/index.html","id":"graph-basics","dir":"","previous_headings":"","what":"Graph Basics","title":"Graph/Network Visualization","text":"Let’s create graph object create_graph() add nodes edges . node gets new integer ID upon creation. edge also gets ID starting 1. pipes functions make whole process readable understandable. can take away edge using delete_edge(). can add node graph , time, defining edges existing nodes graph. Viewing graph object console provide basic information graph pointers get additional information. time add node edge graph, can add node edge aesthetic data attributes. can styling properties (e.g., color, shape), grouping labels (e.g., type rel), data values useful calculations display purposes. node edge creation functions (depending whether create either edges, nodes, ) arguments node_aes, edge_aes, node_data, edge_data. Using , can call namesake helper functions (node_aes(), edge_aes(), node_data(), edge_data()) specifically target created nodes edges bind attribute data. additional benefit using helper functions (node/edge aesthetic attributes especially) RStudio can provide inline help attribute names definitions typing node_aes( edge_aes( pressing TAB key. example adding node setting color, fillcolor, fontcolor node aesthetic attributes, , adding edge color, arrowhead, tooltip edge aesthetic attributes. add_node() add_edge() calls, new node edge set value node/edge data attribute. Creating attributes setting values often useful can work attributes (e.g., mutate values even use traversals). Furthermore, can create aesthetic properties based numerical categorical data. important want display graph diagram using render_graph() function. Don’t worry attribute values weren’t set right creation associated nodes edges. ways set attribute values existing nodes edges. Functions available targeting specific nodes/edges (.e., making selection) functions used set attribute values selected nodes edges. Often, can efficient strategy can target nodes/edges based properties (e.g., degree, relationships neighbors, etc.). example select node based value attribute modify color node aesthetic attribute: explain bit, take graph object d_graph, select nodes node value attribute exactly 2.5. (now active node selection.) selected nodes, set node attribute fillcolor value orange. deactivate selection clear_selection(). Now, view graph render_graph() get : quite functions allow select nodes (e.g., select_nodes(), select_nodes_by_id(), select_last_nodes_created()) edges (e.g., select_edges(), select_edges_by_edge_id(), select_last_edges_created()). selections, can apply changes using functions end ..._ws() (selection). seen, node attributes set/replaced set_node_attrs_ws() can also mutate attributes selected nodes (mutate_node_attrs_ws()), delete selected nodes (delete_nodes_ws()), even create subgraph selection (create_subgraph_ws()). Selections nodes edges can inverted (non-selected nodes edges become active selection) invert_selection(), certain nodes/edges can removed active selection deselect_nodes()/deselect_edges(), selection can eventually cleared clear_selection(). can create graph object add graph primitives paths, cycles, trees . can add one randomly generated graphs graph object. , let’s add directed GNM graph 10 nodes 15 edges (set_seed option makes random graph reproducible). undirected version graph can made using: can view graph using render_graph(). several layouts choose well (e.g., nicely, tree, kk, fr, etc.).","code":"a_graph <- create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 1, to = 2) b_graph <- a_graph %>% delete_edge(from = 1, to = 2) c_graph <- b_graph %>% add_node(from = 1, to = 2) c_graph #> DiagrammeR Graph // 3 nodes / 2 edges #> -- directed / connected / DAG / simple #> #> NODES / type: / label: info: `get_node_df()` #> -- no additional node attributes #> EDGES / rel: info: `get_edge_df()` #> -- no additional edge attributes #> SELECTION / #> CACHE / #> GLOBAL ATTRS / 17 are set info: `get_global_graph_attr_info()` #> GRAPH ACTIONS / #> GRAPH LOG / <3 actions> -> add_edge() -> delete_edge() -> add_node() d_graph <- c_graph %>% add_node( type = \"type_a\", node_aes = node_aes( color = \"steelblue\", fillcolor = \"lightblue\", fontcolor = \"gray35\" ), node_data = node_data( value = 2.5 ) ) %>% add_edge( from = 1, to = 3, rel = \"interacted_with\", edge_aes = edge_aes( color = \"red\", arrowhead = \"vee\", tooltip = \"Red Arrow\" ), edge_data = edge_data( value = 5.2 ) ) e_graph <- d_graph %>% select_nodes(conditions = value == 2.5) %>% set_node_attrs_ws(node_attr = fillcolor, value = \"orange\") %>% clear_selection() f_graph <- create_graph() %>% add_path(n = 3) %>% add_cycle(n = 4) %>% add_balanced_tree(k = 2, h = 2) g_graph <- create_graph() %>% add_gnm_graph( n = 15, m = 20, set_seed = 23 ) h_graph <- create_graph(directed = FALSE) %>% add_gnm_graph( n = 15, m = 20, set_seed = 23 ) render_graph(h_graph, layout = \"fr\")"},{"path":"/index.html","id":"using-data-from-tables-to-generate-a-graph","dir":"","previous_headings":"","what":"Using Data from Tables to Generate a Graph","title":"Graph/Network Visualization","text":"DiagrammeR package contains simple datasets help illustrate create graph table data. node_list_1 edge_list_1 datasets super simple node edge data frames can assembled graph. Let’s print side side see ’re working . fashion graph, need ensure nodes attributes (case, just label) added, , edges added. Furthermore, must map definitions node id (cases, may need map relationships text labels text attribute stored node data frame). can use three functions generate graph containing data: create_graph() add_nodes_from_table() add_edges_from_table() Let’s show process stepwise fashion (occasionally viewing graph’s internal ndf edf) can understand actually happening. First, create graph object create_graph(): Add nodes table add_nodes_from_table(): Inspect graph’s internal node data frame (ndf) get_node_df(): graph now 10 nodes (edges yet). node automatically assigned auto-incrementing id. incoming id also automatically renamed id_external avoid duplicate column names also retain column mapping edge definitions. Now, let’s add edges. need specify from_col edge_list_1 table indeed to_col . from_to_map argument expects node attribute column columns map . case ’s id_external. Note id also matches perfectly mapping, may cases id won’t match id_external column (e.g., existing nodes node id values incoming table provided different order, etc.). Now, connect graph nodes edges another dataset using add_edges_from_table(): Inspect graph’s internal edge data frame (edf) get_edge_df(): supplying name graph object console, can get succinct summary graph’s properties. , see graph 10 nodes 19 edges: two similar datasets included package (node_list_2 edge_list_2). contain extended attribute data. Let’s quick look column names: unique labels label column, categorical labels type rel columns, can create property graph data. Like , can incorporate two tables graph add_nodes_from_table() add_edges_from_table(). time, ’ll remove auto-generated id_external node attribute drop_node_attrs() function. Let’s view graph summary console. Note additional node attributes (value_1 value_2) present nodes edges: Now, node/edge metadata (categorical labels numerical data value_1 & value_2 nodes edges), can interesting things graph. First, let’s mutation mutate_node_attrs() mutate_edge_attrs() get sums value_1 value_2 value_3 (nodes edges). , let’s color nodes edges forestgreen value_3 greater 10 (red otherwise). Finally, let’s display values value_3 nodes rendering graph diagram. go!","code":"node_list_1 edge_list_1 id label from to 1 1 A 1 1 2 2 2 B 2 1 3 3 3 C 3 1 4 4 4 D 4 1 9 5 5 E 5 2 8 6 6 F 6 2 7 7 7 G 7 2 1 8 8 H 8 2 10 9 9 I 9 3 1 10 10 J 10 3 6 11 3 8 12 4 1 13 5 7 14 6 2 15 6 9 16 8 1 17 9 3 18 9 10 19 10 1 # Create the graph object i_graph_1 <- create_graph() # It will start off as empty i_graph_1 %>% is_graph_empty() #> [1] TRUE # Add the nodes to the graph i_graph_2 <- i_graph_1 %>% add_nodes_from_table( table = node_list_1, label_col = label ) # View the graph's internal node data frame i_graph_2 %>% get_node_df() #> id type label id_external #> 1 1 A 1 #> 2 2 B 2 #> 3 3 C 3 #> 4 4 D 4 #> 5 5 E 5 #> 6 6 F 6 #> 7 7 G 7 #> 8 8 H 8 #> 9 9 I 9 #> 10 10 J 10 # Add the edges to the graph i_graph_3 <- i_graph_2 %>% add_edges_from_table( table = edge_list_1, from_col = from, to_col = to, from_to_map = id_external ) # View the edge data frame i_graph_3 %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 1 3 #> 3 3 1 4 #> 4 4 1 9 #> 5 5 2 8 #> 6 6 2 7 #> 7 7 2 1 #> 8 8 2 10 #> 9 9 3 1 #> 10 10 3 6 #> 11 11 3 8 #> 12 12 4 1 #> 13 13 5 7 #> 14 14 6 2 #> 15 15 6 9 #> 16 16 8 1 #> 17 17 9 3 #> 18 18 9 10 #> 19 19 10 1 i_graph_3 #> DiagrammeR Graph // 10 nodes / 19 edges #> -- directed / connected / simple #> #> NODES / type: / label: 10 vals - complete & unique #> -- 1 additional node attribute (id_external) #> EDGES / rel: info: `get_edge_df()` #> -- no additional edge attributes #> SELECTION / #> CACHE / #> GLOBAL ATTRS / 17 are set info: `get_global_graph_attr_info()` #> GRAPH ACTIONS / #> GRAPH LOG / <1 action> -> add_nodes_from_table() -> add_edges_from_table() -> () colnames(node_list_2) #> [1] \"id\" \"label\" \"type\" \"value_1\" \"value_2\" colnames(edge_list_2) #> [1] \"from\" \"to\" \"rel\" \"value_1\" \"value_2\" j_graph <- create_graph() %>% add_nodes_from_table( table = node_list_2, label_col = label, type_col = type ) %>% add_edges_from_table( table = edge_list_2, from_col = from, to_col = to, from_to_map = id_external, rel_col = rel ) %>% drop_node_attrs(node_attr = id_external) j_graph #> DiagrammeR Graph // 10 nodes / 19 edges #> -- directed / connected / property graph / simple #> #> NODES / type: 2 vals - complete / label: 10 vals - complete & unique #> -- 2 additional node attributes (value_1, value_2) #> EDGES / rel: 3 vals - complete info: `get_edge_df()` #> -- 2 additional edge attributes (value_1, value_2) #> SELECTION / #> CACHE / #> GLOBAL ATTRS / 17 are set info: `get_global_graph_attr_info()` #> GRAPH ACTIONS / #> GRAPH LOG / <3 actions> -> add_edges_from_table() -> () -> drop_node_attrs() k_graph <- j_graph %>% mutate_node_attrs(value_3 = value_1 + value_2) %>% mutate_edge_attrs(value_3 = value_1 + value_2) %>% select_nodes(conditions = value_3 > 10) %>% set_node_attrs_ws(node_attr = fillcolor, value = \"forestgreen\") %>% invert_selection() %>% set_node_attrs_ws(node_attr = fillcolor, value = \"red\") %>% select_edges(conditions = value_3 > 10) %>% set_edge_attrs_ws(edge_attr = color, value = \"forestgreen\") %>% invert_selection() %>% set_edge_attrs_ws(edge_attr = color, value = \"red\") %>% clear_selection() %>% set_node_attr_to_display(attr = value_3) render_graph(k_graph)"},{"path":"/index.html","id":"a-network-graph-example","dir":"","previous_headings":"","what":"A Network Graph Example","title":"Graph/Network Visualization","text":"Let’s create property graph pertains contributors three software projects. graph nodes representing people projects. attributes name, age, join_date, email, follower_count, following_count, starred_count specific person nodes project, start_date, stars, language attributes apply project nodes. edges represent relationships people project. example graph file repository.dgr available extdata/example_graphs_dgr/ directory DiagrammeR package (currently, GitHub version). can load memory using open_graph() function, system.file() helps provide location file within package. can always view property graph render_graph() function: Now graph set , can create queries magrittr pipelines get specific answers graph. Get average age contributors. Select nodes type person (project). node type non-NA age attribute, , get attribute vector get_node_attrs_ws() calculate mean R’s mean() function. can get total number commits projects. know edges contain numerical commits attribute, , select edges (select_edges() selects edges graph). , get numeric vector commits values get sum() (commits projects). Single one known Josh get total number commits maintainer contributor. Start selecting Josh node select_nodes(conditions = name == \"Josh\"). graph, know people edge project edge can relationship (rel) type contributor maintainer. can migrate selection nodes outbound edges trav_out_edges() (won’t provide condition, just outgoing edges Josh selected). Now selection 2 edges. Get vector commits values get_edge_attrs_ws() calculate sum(). total number commits. Get total number commits Louisa, just maintainer role though. case ’ll supply condition trav_out_edge(). acts filter traversal means selection applied edges condition met. Although single value, ’ll still use sum() get_edge_attrs_ws() (good practice may know vector length, especially big graphs). something complex, like, get names people graph age 32? First, select person nodes select_nodes(conditions = type == \"person\"). , follow another select_nodes() call specifying age > 32. Importantly, set_op = \"intersect\" (giving us intersection selections). Now starting selection nodes want, need get values nodes’ name attribute character vector. get_node_attrs_ws() function. getting vector, sort names alphabetically R function sort(). get named vector, can use unname() show us names vector component. supercalc project progressing quite nicely. Let’s get total number commits people interesting project. Start selecting project’s node work backwards. Traverse edges leading trav_in_edge(). edges committers contain commits attribute numerical values. Get vector commits get sum (1676 commits). Kim now contributor stringbuildeR project made 15 new commits project. can modify graph reflect . First, add edge add_edge(). Note add_edge() usually relies node IDs creating new edge. almost always inconvenient can instead use node labels (know unique graph) compose edge, setting use_labels = TRUE. rel value add_edge() set contributor – property graph always values set node type edge rel attributes. set another attribute edge (commits) first selecting edge (last edge made, can use select_last_edges_created()), , use set_edge_attrs_ws() provide attribute/value pair. Finally, clear active selections clear_selection(). graph now changed, look. Get email addresses contributors (maintainers) randomizer supercalc88 projects. trav_in_edge() just want contributer edges/commits. edges, hop back unconditionally people edges originate trav_out_node(). Get email values selected individuals sorted character vector. people committed one project? matter node degree. know people edges outward projects edges inward. Thus, anybody outdegree (number edges outward) greater 1 committed one project. Globally, select nodes condition using select_nodes_by_degree(\"outdeg > 1\"). getting name attribute values node selection, can provide sorted character vector names.","code":"# Load in a the small repository graph graph <- open_graph( system.file( \"extdata/example_graphs_dgr/repository.dgr\", package = \"DiagrammeR\" ) ) render_graph(graph, layout = \"kk\") graph %>% select_nodes(conditions = type == \"person\") %>% get_node_attrs_ws(node_attr = age) %>% mean() #> [1] 33.6 graph %>% select_edges() %>% get_edge_attrs_ws(edge_attr = commits) %>% sum() #> [1] 5182 graph %>% select_nodes(conditions = name == \"Josh\") %>% trav_out_edge() %>% get_edge_attrs_ws(edge_attr = commits) %>% sum() #> [1] 227 graph %>% select_nodes(conditions = name == \"Louisa\") %>% trav_out_edge(conditions = rel == \"maintainer\") %>% get_edge_attrs_ws(edge_attr = commits) %>% sum() #> [1] 236 graph %>% select_nodes(conditions = type == \"person\") %>% select_nodes(conditions = age > 32, set_op = \"intersect\") %>% get_node_attrs_ws(node_attr = name) %>% sort() %>% unname() #> [1] \"Jack\" \"Jon\" \"Kim\" \"Roger\" \"Sheryl\" graph %>% select_nodes(conditions = project == \"supercalc\") %>% trav_in_edge() %>% get_edge_attrs_ws(edge_attr = commits) %>% sum() #> [1] 1676 graph <- graph %>% add_edge( from = \"Kim\", to = \"stringbuildeR\", rel = \"contributor\" ) %>% select_last_edges_created() %>% set_edge_attrs_ws(edge_attr = commits, value = 15) %>% clear_selection() render_graph(graph, layout = \"kk\") graph %>% select_nodes( conditions = project == \"randomizer\" | project == \"supercalc\" ) %>% trav_in_edge(conditions = rel == \"contributor\") %>% trav_out_node() %>% get_node_attrs_ws(node_attr = email) %>% sort() %>% unname() #> [1] \"j_2000@ultramail.io\" \"josh_ch@megamail.kn\" #> [3] \"kim_3251323@ohhh.ai\" \"lhe99@mailing-fun.com\" #> [5] \"roger_that@whalemail.net\" \"the_simone@a-q-w-o.net\" #> [7] \"the_will@graphymail.com\" graph %>% select_nodes_by_degree(expressions = \"outdeg > 1\") %>% get_node_attrs_ws(node_attr = name) %>% sort() %>% unname() #> [1] \"Josh\" \"Kim\" \"Louisa\""},{"path":"/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Graph/Network Visualization","text":"DiagrammeR used R environment. don’t R installation, can obtained Comprehensive R Archive Network (CRAN). can install development version DiagrammeR GitHub using devtools package. , get CRAN. encounter bug, usage questions, want share ideas make package better, feel free file issue.","code":"devtools::install_github(\"rich-iannone/DiagrammeR\") install.packages(\"DiagrammeR\")"},{"path":"/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Graph/Network Visualization","text":"Please note DiagrammeR project released contributor code conduct.participating project agree abide terms.","code":""},{"path":"/index.html","id":"id_-license","dir":"","previous_headings":"","what":"📄 License","title":"Graph/Network Visualization","text":"DiagrammeR licensed MIT license. See LICENSE.md file details.","code":""},{"path":"/index.html","id":"id_️-governance","dir":"","previous_headings":"","what":"🏛️ Governance","title":"Graph/Network Visualization","text":"project primarily maintained Rich Iannone. authors may occasionally assist duties.","code":""},{"path":"/reference/DiagrammeR-package.html","id":null,"dir":"Reference","previous_headings":"","what":"DiagrammeR: Graph/Network Visualization — DiagrammeR-package","title":"DiagrammeR: Graph/Network Visualization — DiagrammeR-package","text":"Build graph/network structures using functions stepwise addition deletion nodes edges. Work data available tables bulk addition nodes, edges, associated metadata. Use graph selections traversals apply changes specific nodes edges. wide selection graph algorithms allow analysis graphs. Visualize graphs take advantage aesthetic properties assigned nodes edges.","code":""},{"path":[]},{"path":"/reference/DiagrammeR-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"DiagrammeR: Graph/Network Visualization — DiagrammeR-package","text":"Maintainer: Richard Iannone riannone@.com (ORCID)","code":""},{"path":"/reference/DiagrammeR.html","id":null,"dir":"Reference","previous_headings":"","what":"R + mermaid.js — DiagrammeR","title":"R + mermaid.js — DiagrammeR","text":"Make diagrams R using viz.js mermaid.js infrastructure provided htmlwidgets.","code":""},{"path":"/reference/DiagrammeR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"R + mermaid.js — DiagrammeR","text":"","code":"DiagrammeR(diagram = \"\", type = \"mermaid\", ...)"},{"path":"/reference/DiagrammeR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"R + mermaid.js — DiagrammeR","text":"diagram diagram graphviz mermaid format, , file (connection file name) containing diagram specification. recommended filename extensions .gv .mmd Graphviz mermaid diagram specifications, respectively. diagram provided (diagram = \"\") function assume diagram provided htmltools::tags() DiagrammeR just used dependency injection. type string, either mermaid (default) grViz indicating type diagram spec desired parser/renderer. ... parameters pass grViz mermaid","code":""},{"path":"/reference/DiagrammeR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"R + mermaid.js — DiagrammeR","text":"object class htmlwidget intelligently print HTML variety contexts including R console, within R Markdown documents, within Shiny output bindings.","code":""},{"path":"/reference/DiagrammeR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"R + mermaid.js — DiagrammeR","text":"","code":"if (FALSE) { # note the whitespace is not important DiagrammeR(\" graph LR A-->B A-->C C-->E B-->D C-->D D-->F E-->F \") DiagrammeR(\" graph TB A-->B A-->C C-->E B-->D C-->D D-->F E-->F \") DiagrammeR(\"graph LR;A(Rounded)-->B[Squared];B-->C{A Decision}; C-->D[Square One];C-->E[Square Two]; style A fill:#E5E25F; style B fill:#87AB51; style C fill:#3C8937; style D fill:#23772C; style E fill:#B6E6E6;\" ) # Load in the 'mtcars' dataset data(mtcars) connections <- sapply( 1:ncol(mtcars) ,function(i) { paste0( i ,\"(\",colnames(mtcars)[i],\")---\" ,i,\"-stats(\" ,paste0( names(summary(mtcars[,i])) ,\": \" ,unname(summary(mtcars[,i])) ,collapse=\"
    \" ) ,\")\" ) } ) DiagrammeR( paste0( \"graph TD;\", \"\\n\", paste(connections, collapse = \"\\n\"),\"\\n\", \"classDef column fill:#0001CC, stroke:#0D3FF3, stroke-width:1px;\" ,\"\\n\", \"class \", paste0(1:length(connections), collapse = \",\"), \" column;\" ) ) # also with DiagrammeR() you can use tags from htmltools # just make sure to use class = \"mermaid\" library(htmltools) diagramSpec = \" graph LR; id1(Start)-->id2(Stop); style id1 fill:#f9f,stroke:#333,stroke-width:4px; style id2 fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5; \" html_print(tagList( tags$h1(\"R + mermaid.js = Something Special\") ,tags$pre(diagramSpec) ,tags$div(class=\"mermaid\",diagramSpec) ,DiagrammeR() )) # sequence diagrams # Using this \"How to Draw a Sequence Diagram\" # http://www.cs.uku.fi/research/publications/reports/A-2003-1/page91.pdf # draw some sequence diagrams with DiagrammeR library(DiagrammeR) DiagrammeR(\" sequenceDiagram; customer->>ticket seller: ask for ticket; ticket seller->>database: seats; alt tickets available database->>ticket seller: ok; ticket seller->>customer: confirm; customer->>ticket seller: ok; ticket seller->>database: book a seat; ticket seller->>printer: print ticket; else sold out database->>ticket seller: none left; ticket seller->>customer: sorry; end \") }"},{"path":"/reference/DiagrammeROutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Widget output function for use in Shiny — DiagrammeROutput","title":"Widget output function for use in Shiny — DiagrammeROutput","text":"Widget output function use Shiny","code":""},{"path":"/reference/DiagrammeROutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Widget output function for use in Shiny — DiagrammeROutput","text":"","code":"DiagrammeROutput(outputId, width = \"100%\", height = \"auto\")"},{"path":"/reference/DiagrammeROutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Widget output function for use in Shiny — DiagrammeROutput","text":"outputId Output variable read width valid CSS unit width number, coerced string px appended. height valid CSS unit height number, coerced string px appended.","code":""},{"path":"/reference/add_balanced_tree.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a balanced tree to the graph — add_balanced_tree","title":"Add a balanced tree to the graph — add_balanced_tree","text":"graph object class dgr_graph, add balanced tree graph.","code":""},{"path":"/reference/add_balanced_tree.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a balanced tree to the graph — add_balanced_tree","text":"","code":"add_balanced_tree( graph, k, h, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_balanced_tree.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a balanced tree to the graph — add_balanced_tree","text":"graph graph object class dgr_graph. k branching factor tree. h height tree. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , boolean value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node tree. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_balanced_tree.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a balanced tree to the graph — add_balanced_tree","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_balanced_tree.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a balanced tree to the graph — add_balanced_tree","text":"","code":"# Create a new graph and # add 2 different types of # balanced trees of height # 2 (branching twice) and # different branching ratios graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2, type = \"binary\") %>% add_balanced_tree( k = 3, h = 2, type = \"tertiary\") # Get some node information # from this graph graph %>% get_node_info() %>% head(5) #> id type label deg indeg outdeg loops #> 1 1 binary 1 2 0 2 0 #> 2 2 binary 2 3 1 2 0 #> 3 3 binary 3 3 1 2 0 #> 4 4 binary 4 1 1 0 0 #> 5 5 binary 5 1 1 0 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments graph_w_attrs <- create_graph() %>% add_balanced_tree( k = 2, h = 2, label = c( \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\"), type = c( \"a\", \"b\", \"b\", \"c\", \"c\", \"c\", \"c\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), node_data = node_data( value = c( 1.6, 2.8, 3.4, 8.3, 3.8, 5.2, 3.2)), edge_aes = edge_aes( color = \"red\", penwidth = 1.2)) # Get the first three rows of # the graph's node data frame graph_w_attrs %>% get_node_df() %>% head(3) #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 b two steelblue 2.8 #> 3 3 b three steelblue 3.4 # Get the first three rows of # the graph's edge data frame graph_w_attrs %>% get_edge_df() %>% head(3) #> id from to rel penwidth color #> 1 1 1 2 A 1.2 red #> 2 2 1 3 A 1.2 red #> 3 3 2 4 A 1.2 red"},{"path":"/reference/add_cycle.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a cycle of nodes to the graph — add_cycle","title":"Add a cycle of nodes to the graph — add_cycle","text":"graph object class dgr_graph, add node cycle graph.","code":""},{"path":"/reference/add_cycle.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a cycle of nodes to the graph — add_cycle","text":"","code":"add_cycle( graph, n, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_cycle.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a cycle of nodes to the graph — add_cycle","text":"graph graph object class dgr_graph. n number nodes comprising cycle. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , boolean value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node cycle. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_cycle.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a cycle of nodes to the graph — add_cycle","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_cycle.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a cycle of nodes to the graph — add_cycle","text":"","code":"# Create a new graph and # add a cycle of nodes to it graph <- create_graph() %>% add_cycle(n = 6) # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 1 2 1 1 0 #> 2 2 2 2 1 1 0 #> 3 3 3 2 1 1 0 #> 4 4 4 2 1 1 0 #> 5 5 5 2 1 1 0 #> 6 6 6 2 1 1 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) graph_w_attrs <- create_graph() %>% add_cycle( n = 3, label = c( \"one\", \"two\", \"three\"), type = c( \"a\", \"a\", \"b\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), edge_aes = edge_aes( color = \"red\", penwidth = 1.2), node_data = node_data( value = c( 1.6, 2.8, 3.4)), edge_data = edge_data( value = rnorm( n = 3, mean = 5.0, sd = 1.0))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 a two steelblue 2.8 #> 3 3 b three steelblue 3.4 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 A 1.2 red 5.996605 #> 2 2 2 3 A 1.2 red 6.107490 #> 3 3 3 1 A 1.2 red 4.721914"},{"path":"/reference/add_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Add an edge between nodes in a graph object — add_edge","title":"Add an edge between nodes in a graph object — add_edge","text":"graph object class dgr_graph, add edge nodes within graph.","code":""},{"path":"/reference/add_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add an edge between nodes in a graph object — add_edge","text":"","code":"add_edge(graph, from, to, rel = NULL, edge_aes = NULL, edge_data = NULL)"},{"path":"/reference/add_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add an edge between nodes in a graph object — add_edge","text":"graph graph object class dgr_graph. outgoing node edge connected. option use node label value (must correspondingly also done argument) defining node connections. Note possible nodes distinct label values set none exist empty string. incoming nodes edge connected. option use node label value (must correspondingly also done argument) defining node connections. Note possible nodes distinct label values set none exist empty string. rel optional string specifying relationship connected nodes. edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add an edge between nodes in a graph object — add_edge","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add an edge between nodes in a graph object — add_edge","text":"","code":"# Create a graph with 4 nodes graph <- create_graph() %>% add_node(label = \"one\") %>% add_node(label = \"two\") %>% add_node(label = \"three\") %>% add_node(label = \"four\") # Add an edge between those # nodes and attach a # relationship to the edge graph <- add_edge( graph, from = 1, to = 2, rel = \"A\") # Use the `get_edge_info()` # function to verify that # the edge has been created graph %>% get_edge_info() #> id from to rel #> 1 1 1 2 A # Add another node and # edge to the graph graph <- graph %>% add_edge( from = 3, to = 2, rel = \"A\") # Verify that the edge # has been created by # counting graph edges graph %>% count_edges() #> [1] 2 # Add edges by specifying # node `label` values; note # that all nodes must have # unique `label` values to # use this option graph <- graph %>% add_edge( from = \"three\", to = \"four\", rel = \"L\") %>% add_edge( from = \"four\", to = \"one\", rel = \"L\") # Use `get_edges()` to verify # that the edges were added graph %>% get_edges() #> [1] \"1->2\" \"3->2\" \"3->4\" \"4->1\" # Add edge aesthetic and data # attributes during edge creation graph_2 <- create_graph() %>% add_n_nodes(n = 2) %>% add_edge( from = 1, to = 2, rel = \"M\", edge_aes = edge_aes( penwidth = 1.5, color = \"blue\"), edge_data = edge_data( value = 4.3)) # Use the `get_edges()` function # to verify that the attribute # values were bound to the # newly created edge graph_2 %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 M 1.5 blue 4.3"},{"path":"/reference/add_edge_clone.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a clone of an existing edge to the graph — add_edge_clone","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"Add new edge graph object class dgr_graph clone edge already graph. edge attributes preserved.","code":""},{"path":"/reference/add_edge_clone.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"","code":"add_edge_clone(graph, edge, from, to)"},{"path":"/reference/add_edge_clone.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"graph graph object class dgr_graph. edge edge ID corresponding graph edge cloned. outgoing node edge connected. incoming nodes edge connected.","code":""},{"path":"/reference/add_edge_clone.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edge_clone.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"","code":"# Create a graph with a path of # 2 nodes; supply a common `rel` # edge attribute for all edges # in this path and then add a # `color` edge attribute graph <- create_graph() %>% add_path( n = 2, rel = \"a\") %>% select_last_edges_created() %>% set_edge_attrs( edge_attr = color, values = \"steelblue\") %>% clear_selection() # Display the graph's internal # edge data frame graph %>% get_edge_df() #> id from to rel color #> 1 1 1 2 a steelblue # Create a new node (will have # node ID of `3`) and then # create an edge between it and # node `1` while reusing the edge # attributes of edge `1` -> `2` # (edge ID `1`) graph_2 <- graph %>% add_node() %>% add_edge_clone( edge = 1, from = 3, to = 1) # Display the graph's internal # edge data frame graph_2 %>% get_edge_df() #> id from to rel color #> 1 1 1 2 a steelblue #> 2 2 3 1 a steelblue # The same change can be performed # with some helper functions in the # `add_edge_clone()` function call graph_3 <- graph %>% add_node() %>% add_edge_clone( edge = get_last_edges_created(.), from = get_last_nodes_created(.), to = 1) # Display the graph's internal # edge data frame graph_3 %>% get_edge_df() #> id from to rel color #> 1 1 1 2 a steelblue #> 2 2 3 1 a steelblue"},{"path":"/reference/add_edge_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Add edges from an edge data frame to an existing graph object — add_edge_df","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"graph object class dgr_graph, add edges edge data frame graph.","code":""},{"path":"/reference/add_edge_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"","code":"add_edge_df(graph, edge_df)"},{"path":"/reference/add_edge_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"graph graph object class dgr_graph. edge_df edge data frame created using create_edge_df().","code":""},{"path":"/reference/add_edge_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edge_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"","code":"# Create a graph with 4 nodes # and no edges graph <- create_graph() %>% add_n_nodes(n = 4) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1)) # Add the edge data frame to # the graph object to create # a graph with both nodes # and edges graph <- graph %>% add_edge_df( edge_df = edf) # Get the graph's edges to # verify that the edf had # been added graph %>% get_edges( return_type = \"vector\") #> [1] \"1->4\" \"2->3\" \"3->1\""},{"path":"/reference/add_edges_from_table.html","id":null,"dir":"Reference","previous_headings":"","what":"Add edges and attributes to graph from a table — add_edges_from_table","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"Add edges attributes existing graph object data CSV file data frame.","code":""},{"path":"/reference/add_edges_from_table.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"","code":"add_edges_from_table( graph, table, from_col, to_col, from_to_map, rel_col = NULL, set_rel = NULL, drop_cols = NULL )"},{"path":"/reference/add_edges_from_table.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"graph graph object class dgr_graph. table Either path CSV file, , data frame object. from_col name table column edges originate. to_col name table column edges terminate. from_to_map single character value mapping columns external table (supplied from_col to_col, respectively) column graph's internal node data frame (ndf). rel_col option apply column data table rel attribute values. set_rel optional string apply rel attribute edges created table records. drop_cols optional column selection statement dropping columns external table inclusion attributes graph's internal edge data frame. Several columns can dropped name using syntax col_1 & col_2 & .... Columns can also dropped using numeric column range : (e.g., 5:8), , using : column names specify range (e.g., col_5_name:col_8_name).","code":""},{"path":"/reference/add_edges_from_table.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edges_from_table.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"","code":"# Create an empty graph and then # add nodes to it from the # `currencies` dataset available # in the package graph <- create_graph() %>% add_nodes_from_table( table = currencies) # Now we want to add edges to the # graph using an included dataset, # `usd_exchange_rates`, which has # exchange rates between USD and # many other currencies; the key # here is that the data in the # `from` and `to` columns in the # external table maps to graph # node data available in the # `iso_4217_code` column of the # graph's internal node data frame graph_1 <- graph %>% add_edges_from_table( table = usd_exchange_rates, from_col = from_currency, to_col = to_currency, from_to_map = iso_4217_code) # View part of the graph's # internal edge data frame graph_1 %>% get_edge_df() %>% head() #> id from to rel cost_unit #> 1 1 148 1 0.272300 #> 2 2 148 2 0.015210 #> 3 3 148 3 0.008055 #> 4 4 148 4 0.002107 #> 5 5 148 5 0.565000 #> 6 6 148 6 0.006058 # If you would like to assign # any of the table's columns as the # `rel` attribute, this can done # with the `rel_col` argument; to # set a static `rel` attribute for # all edges created, use `set_rel` graph_2 <- graph %>% add_edges_from_table( table = usd_exchange_rates, from_col = from_currency, to_col = to_currency, from_to_map = iso_4217_code, set_rel = \"from_usd\") # View part of the graph's internal # edge data frame (edf) graph_2 %>% get_edge_df() %>% head() #> id from to rel cost_unit #> 1 1 148 1 from_usd 0.272300 #> 2 2 148 2 from_usd 0.015210 #> 3 3 148 3 from_usd 0.008055 #> 4 4 148 4 from_usd 0.002107 #> 5 5 148 5 from_usd 0.565000 #> 6 6 148 6 from_usd 0.006058"},{"path":"/reference/add_edges_w_string.html","id":null,"dir":"Reference","previous_headings":"","what":"Add one or more edges using a text string — add_edges_w_string","title":"Add one or more edges using a text string — add_edges_w_string","text":"graph object class dgr_graph, add one edges graph using text string.","code":""},{"path":"/reference/add_edges_w_string.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add one or more edges using a text string — add_edges_w_string","text":"","code":"add_edges_w_string(graph, edges, rel = NULL, use_labels = FALSE)"},{"path":"/reference/add_edges_w_string.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add one or more edges using a text string — add_edges_w_string","text":"graph graph object class dgr_graph. edges single-length vector character string specifying edges. directed graph, string object formatted series node ID values [node_ID_1]->[node_ID_2] separated one space characters. undirected graphs, -- replace ->. Line breaks vector cause error. rel optional vector specifying relationship connected nodes. use_labels option use node label values edges string define node connections. Note possible nodes distinct label values set none exist empty string.","code":""},{"path":"/reference/add_edges_w_string.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add one or more edges using a text string — add_edges_w_string","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edges_w_string.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add one or more edges using a text string — add_edges_w_string","text":"","code":"# Create a graph with 4 nodes graph <- create_graph() %>% add_node(label = \"one\") %>% add_node(label = \"two\") %>% add_node(label = \"three\") %>% add_node(label = \"four\") # Add edges between nodes using # a character string with node # ID values graph_node_id <- graph %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->3\") # Show the graph's internal # edge data frame graph_node_id %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 1 3 #> 3 3 2 4 #> 4 4 2 3 # Add edges between nodes using # a character string with node # label values and setting # `use_labels = TRUE`; note that # all nodes must have unique # `label` values to use this graph_node_label <- graph %>% add_edges_w_string( edges = \"one->two one->three two->four two->three\", use_labels = TRUE) # Show the graph's internal # edge data frame (it's the # same as before) graph_node_label %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 1 3 #> 3 3 2 4 #> 4 4 2 3 "},{"path":"/reference/add_forward_edges_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"Add edges direction one edges available edge selection graph object class dgr_graph. New graph edges edge definitions selection except new edge ID values. also option assign common rel grouping newly created edges. Upon addition edges, edge selection retained selection traversal operations. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/add_forward_edges_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"","code":"add_forward_edges_ws(graph, rel = NULL)"},{"path":"/reference/add_forward_edges_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"graph graph object class dgr_graph. rel optional string apply rel attribute newly created edges.","code":""},{"path":"/reference/add_forward_edges_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_forward_edges_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"","code":"# Create an empty graph, add 2 nodes # to it, and create the edge `1->2` graph <- create_graph() %>% add_n_nodes( n = 2, type = \"type_a\", label = c(\"a_1\", \"a_2\")) %>% add_edge( from = 1, to = 2, rel = \"a\") # Get the graph's edges graph %>% get_edge_ids() #> [1] 1 # Select the edge and create 2 # additional edges with the same # definition (`1->2`) but with # different `rel` values (`b` and `c`) graph <- graph %>% select_edges() %>% add_forward_edges_ws(rel = \"b\") %>% add_forward_edges_ws(rel = \"c\") %>% clear_selection() # Get the graph's edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 a #> 2 2 1 2 b #> 3 3 1 2 c"},{"path":"/reference/add_full_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a fully connected graph — add_full_graph","title":"Add a fully connected graph — add_full_graph","text":"graph object class dgr_graph, add fully connected graph either without loops. graph object set directed, added graph edges pair nodes. undirected case, single edge link pair nodes.","code":""},{"path":"/reference/add_full_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a fully connected graph — add_full_graph","text":"","code":"add_full_graph( graph, n, type = NULL, label = TRUE, rel = NULL, edge_wt_matrix = NULL, keep_loops = FALSE, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_full_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a fully connected graph — add_full_graph","text":"graph graph object class dgr_graph. n number nodes comprising fully connected graph. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , boolean value setting TRUE ascribes node IDs label FALSE NULL yields blank label. rel optional string providing relationship label new edges created connected graph. edge_wt_matrix optional matrix n n dimensions containing values apply edge weights. matrix row names column names label = TRUE, row column names used node label values. keep_loops option simplify fully connected graph removing loops (edges node). default value FALSE. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_full_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a fully connected graph — add_full_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_full_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a fully connected graph — add_full_graph","text":"","code":"# Create a new graph object # and add a directed and fully # connected graph with 3 nodes # and edges to and from all # pairs of nodes; with the option # `keep_loops = TRUE` nodes # will also have edges from # and to themselves graph <- create_graph() %>% add_full_graph( n = 3, keep_loops = TRUE ) # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 1 6 3 3 1 #> 2 2 2 6 3 3 1 #> 3 3 3 6 3 3 1 # Using `keep_loops = FALSE` # (the default) will remove # the loops create_graph() %>% add_full_graph(n = 3) %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 1 4 2 2 0 #> 2 2 2 4 2 2 0 #> 3 3 3 4 2 2 0 # Values can be set for # the node `label`, node # `type`, and edge `rel` graph <- create_graph() %>% add_full_graph( n = 3, type = \"connected\", label = c(\"1st\", \"2nd\", \"3rd\"), rel = \"connected_to\" ) # Show the graph's node # data frame (ndf) graph %>% get_node_df() #> id type label #> 1 1 connected 1st #> 2 2 connected 2nd #> 3 3 connected 3rd # Show the graph's edge # data frame (edf) graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 connected_to #> 2 2 1 3 connected_to #> 3 3 2 1 connected_to #> 4 4 2 3 connected_to #> 5 5 3 1 connected_to #> 6 6 3 2 connected_to # Create a fully-connected and # directed graph with 3 nodes, # and, where a matrix provides # edge weights; first, create the # matrix (with row names to be # used as node labels) suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) edge_wt_matrix <- rnorm(100, 5, 2) %>% sample(9, FALSE) %>% round(2) %>% matrix( ncol = 3, nrow = 3, dimnames = list(c(\"a\", \"b\", \"c\")) ) # Create the fully-connected # graph (without loops however) graph <- create_graph() %>% add_full_graph( n = 3, type = \"weighted\", label = TRUE, rel = \"related_to\", edge_wt_matrix = edge_wt_matrix, keep_loops = FALSE) # Show the graph's node # data frame (ndf) graph %>% get_node_df() #> id type label #> 1 1 weighted a #> 2 2 weighted b #> 3 3 weighted c # Show the graph's edge # data frame (edf) graph %>% get_edge_df() #> id from to rel weight #> 1 1 1 2 related_to 3.30 #> 2 2 1 3 related_to 5.02 #> 3 3 2 1 related_to 4.13 #> 4 4 2 3 related_to 6.49 #> 5 5 3 1 related_to 6.03 #> 6 6 3 2 related_to 5.55 # An undirected graph can # also use a matrix with # edge weights, but only # the lower triangle of # that matrix will be used create_graph(directed = FALSE) %>% add_full_graph( n = 3, type = \"weighted\", label = TRUE, rel = \"related_to\", edge_wt_matrix = edge_wt_matrix, keep_loops = FALSE ) %>% get_edge_df() #> id from to rel weight #> 1 1 1 2 related_to 3.30 #> 2 2 1 3 related_to 5.02 #> 3 3 2 3 related_to 6.49"},{"path":"/reference/add_global_graph_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Add one or more global graph attributes — add_global_graph_attrs","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"Add global attributes specific type (either graph_attrs, node_attrs, edge_attrs graph object class dgr_graph).","code":""},{"path":"/reference/add_global_graph_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"","code":"add_global_graph_attrs(graph, attr, value, attr_type)"},{"path":"/reference/add_global_graph_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"graph graph object class dgr_graph. attr name attribute set type global attribute specified. value value set chosen attribute specified attr_for_type argument. attr_type specific type global graph attribute set. type specified graph, node, edge.","code":""},{"path":"/reference/add_global_graph_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_global_graph_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"","code":"# Create a new graph with no # global graph attributes and # add a global graph attribute graph <- create_graph( attr_theme = NULL) %>% add_global_graph_attrs( attr = \"overlap\", value = \"true\", attr_type = \"graph\") # Verify that the attribute # addition has been made graph %>% get_global_graph_attr_info() #> # A tibble: 1 × 3 #> attr value attr_type #> #> 1 overlap true graph # Add another attribute with # `add_global_graph_attrs()` graph <- graph %>% add_global_graph_attrs( attr = \"penwidth\", value = 12, attr_type = \"node\") # Verify that the attribute # addition has been made graph %>% get_global_graph_attr_info() #> # A tibble: 2 × 3 #> attr value attr_type #> #> 1 overlap true graph #> 2 penwidth 12 node # When adding an attribute where # `attr` and `attr_type` already # exists, the value provided will # serve as an update graph %>% add_global_graph_attrs( attr = \"penwidth\", value = 15, attr_type = \"node\") %>% get_global_graph_attr_info() #> # A tibble: 2 × 3 #> attr value attr_type #> #> 1 overlap true graph #> 2 penwidth 15 node"},{"path":"/reference/add_gnm_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"existing graph object, add graph built according Erdos-Renyi G(n, m) model. uses constant probability creating fixed number edges. Thus n nodes m edges , loops argument set TRUE, random loop edges part m.","code":""},{"path":"/reference/add_gnm_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"","code":"add_gnm_graph( graph, n, m, loops = FALSE, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_gnm_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"graph graph object class dgr_graph. n number nodes comprising generated graph. m number edges generated graph. loops logical value (default FALSE) governs whether loops allowed created. type optional string describes entity type nodes added. label boolean value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_gnm_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_gnm_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"","code":"# Create an undirected GNM # graph with 100 nodes and # 120 edges gnm_graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 100, m = 120) # Get a count of nodes gnm_graph %>% count_nodes() #> [1] 100 # Get a count of edges gnm_graph %>% count_edges() #> [1] 120"},{"path":"/reference/add_gnp_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"existing graph object, add graph built according Erdos-Renyi G(n, p) model, uses constant probability creating edges.","code":""},{"path":"/reference/add_gnp_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"","code":"add_gnp_graph( graph, n, p, loops = FALSE, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_gnp_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"graph graph object class dgr_graph. n number nodes comprising generated graph. p probability creating edge two arbitrary nodes. loops logical value (default FALSE) governs whether loops allowed created. type optional string describes entity type nodes added. label boolean value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_gnp_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_gnp_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"","code":"# Create an undirected GNP # graph with 100 nodes using # a probability value of 0.05 gnp_graph <- create_graph( directed = FALSE) %>% add_gnp_graph( n = 100, p = 0.05) # Get a count of nodes gnp_graph %>% count_nodes() #> [1] 100 # Get a count of edges gnp_graph %>% count_edges() #> [1] 212"},{"path":"/reference/add_graph_action.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a graph action for execution at every transform — add_graph_action","title":"Add a graph action for execution at every transform — add_graph_action","text":"Add graph function along arguments run every graph transformation step.","code":""},{"path":"/reference/add_graph_action.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a graph action for execution at every transform — add_graph_action","text":"","code":"add_graph_action(graph, fcn, ..., action_name = NULL)"},{"path":"/reference/add_graph_action.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a graph action for execution at every transform — add_graph_action","text":"graph graph object class dgr_graph. fcn name function use. ... Arguments values pass named function fcn, necessary. action_name optional name labeling action.","code":""},{"path":"/reference/add_graph_action.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a graph action for execution at every transform — add_graph_action","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_graph_action.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a graph action for execution at every transform — add_graph_action","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 22, set_seed = 23) # Add a graph action that sets a node # attr column with a function; the # main function `set_node_attr_w_fcn()` # uses the `get_betweenness()` function # to provide betweenness values in the # `btwns` column; this action will # occur whenever there is a function # called on the graph that modifies it # (e.g., `add_n_nodes()`) graph <- graph %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_betweenness\", column_name = \"btwns\", action_name = \"get_btwns\") # To ensure that the action is # available in the graph, use the # `get_graph_actions()` function graph %>% get_graph_actions() #> # A tibble: 1 × 3 #> action_index action_name expression #> #> 1 1 get_btwns set_node_attr_w_fcn(graph = graph, node_attr_fcn = '…"},{"path":"/reference/add_graph_to_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Add graph object to a graph series object — add_graph_to_graph_series","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"Add graph object extant graph series object storage multiple graphs across sequential temporal one-dimensional array.","code":""},{"path":"/reference/add_graph_to_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"","code":"add_graph_to_graph_series(graph_series, graph)"},{"path":"/reference/add_graph_to_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"graph_series graph series object graph object added. graph graph object add graph series object.","code":""},{"path":"/reference/add_graph_to_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"graph series object type dgr_graph_1D.","code":""},{"path":"/reference/add_graph_to_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Count the number of graphs # in the graph series series %>% count_graphs_in_graph_series() #> [1] 3"},{"path":"/reference/add_grid_2d.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a 2D grid of nodes to the graph — add_grid_2d","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"graph object class dgr_graph, add two-dimensional grid graph.","code":""},{"path":"/reference/add_grid_2d.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"","code":"add_grid_2d( graph, x, y, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_grid_2d.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"graph graph object class dgr_graph. x number nodes x direction. y number nodes y direction. type optional string describes entity type nodes added. label Either vector object length x * y provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created grid. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_grid_2d.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_grid_2d.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"","code":"# Create a new graph and add # a 3 x 3 grid graph <- create_graph() %>% add_grid_2d( x = 3, y = 3, type = \"grid\") # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 grid 1 2 0 2 0 #> 2 2 grid 2 3 1 2 0 #> 3 3 grid 3 2 1 1 0 #> 4 4 grid 4 3 1 2 0 #> 5 5 grid 5 4 2 2 0 #> 6 6 grid 6 3 2 1 0 #> 7 7 grid 7 2 1 1 0 #> 8 8 grid 8 3 2 1 0 #> 9 9 grid 9 2 2 0 0 # Attributes can be specified # in extra arguments and these # are applied in order; Usually # these attributes are applied # to nodes (e.g., `type` is a # node attribute) but the `rel` # attribute will apply to the # edges graph_w_attrs <- create_graph() %>% add_grid_2d( x = 3, y = 2, label = c(\"one\", \"two\", \"three\", \"four\", \"five\", \"six\"), type = c(\"a\", \"a\", \"b\", \"b\", \"c\", \"c\"), rel = \"grid\", node_data = node_data( value = c( 1.2, 8.4, 3.4, 5.2, 6.1, 2.6))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label value #> 1 1 a one 1.2 #> 2 2 a two 8.4 #> 3 3 b three 3.4 #> 4 4 b four 5.2 #> 5 5 c five 6.1 #> 6 6 c six 2.6 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel #> 1 1 1 2 grid #> 2 2 1 4 grid #> 3 3 2 3 grid #> 4 4 2 5 grid #> 5 5 3 6 grid #> 6 6 4 5 grid #> 7 7 5 6 grid"},{"path":"/reference/add_grid_3d.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a 3D grid of nodes to the graph — add_grid_3d","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"graph object class dgr_graph, add three-dimensional grid graph.","code":""},{"path":"/reference/add_grid_3d.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"","code":"add_grid_3d( graph, x, y, z, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_grid_3d.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"graph graph object class dgr_graph. x number nodes x direction. y number nodes y direction. z number nodes z direction. type optional string describes entity type nodes added. label Either vector object length x * y * z provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created grid. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_grid_3d.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_grid_3d.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"","code":"# Create a new graph and add # a 2 x 2 x 2 grid graph <- create_graph() %>% add_grid_3d( x = 2, y = 2, z = 2, type = \"grid\") # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 grid 1 3 0 3 0 #> 2 2 grid 2 3 1 2 0 #> 3 3 grid 3 3 1 2 0 #> 4 4 grid 4 3 2 1 0 #> 5 5 grid 5 3 1 2 0 #> 6 6 grid 6 3 2 1 0 #> 7 7 grid 7 3 2 1 0 #> 8 8 grid 8 3 3 0 0 # Attributes can be specified # in extra arguments and these # are applied in order; Usually # these attributes are applied # to nodes (e.g., `type` is a # node attribute) but the `rel` # attribute will apply to the # edges graph_w_attrs <- create_graph() %>% add_grid_3d( x = 2, y = 2, z = 2, label = c( \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\"), type = c( \"a\", \"a\", \"b\", \"b\", \"c\", \"c\", \"d\", \"d\"), rel = \"grid\", node_data = node_data( value = c( 1.2, 8.4, 3.4, 5.2, 6.1, 2.6, 6.3, 9.3))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label value #> 1 1 a one 1.2 #> 2 2 a two 8.4 #> 3 3 b three 3.4 #> 4 4 b four 5.2 #> 5 5 c five 6.1 #> 6 6 c six 2.6 #> 7 7 d seven 6.3 #> 8 8 d eight 9.3 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel #> 1 1 1 2 grid #> 2 2 1 3 grid #> 3 3 1 5 grid #> 4 4 2 4 grid #> 5 5 2 6 grid #> 6 6 3 4 grid #> 7 7 3 7 grid #> 8 8 4 8 grid #> 9 9 5 6 grid #> 10 10 5 7 grid #> 11 11 6 8 grid #> 12 12 7 8 grid"},{"path":"/reference/add_growing_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a random growing graph with m edges added per step — add_growing_graph","title":"Create a random growing graph with m edges added per step — add_growing_graph","text":"existing graph object, add graph built adding m new edges time step (node added).","code":""},{"path":"/reference/add_growing_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a random growing graph with m edges added per step — add_growing_graph","text":"","code":"add_growing_graph( graph, n, m = 1, citation = FALSE, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_growing_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a random growing graph with m edges added per step — add_growing_graph","text":"graph graph object class dgr_graph. n number nodes comprising generated graph. m number edges added per time step. citation logical value (default FALSE) governs whether citation graph created. new edges specifically originate newly added node recent time step. type optional string describes entity type nodes added. label logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_growing_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a random growing graph with m edges added per step — add_growing_graph","text":"","code":"# Create a random, growing # citation graph with 100 # nodes, adding an edge after # each node addition growing_graph <- create_graph() %>% add_growing_graph( n = 100, m = 1, citation = TRUE, set_seed = 23) # Get a count of nodes growing_graph %>% count_nodes() #> [1] 100 # Get a count of edges growing_graph %>% count_edges() #> [1] 99"},{"path":"/reference/add_islands_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a random islands graph with edges between the islands — add_islands_graph","title":"Create a random islands graph with edges between the islands — add_islands_graph","text":"existing graph object, add several Erdos-Renyi random graphs (islands) using common set parameters, connected together fixed number edges.","code":""},{"path":"/reference/add_islands_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a random islands graph with edges between the islands — add_islands_graph","text":"","code":"add_islands_graph( graph, n_islands, island_size, p, edges_between, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_islands_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a random islands graph with edges between the islands — add_islands_graph","text":"graph graph object class dgr_graph. n_islands number islands generated graph. island_size size islands generated graph. p probability edges islands. edges_between number edges islands. type optional string describes entity type nodes added. label logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_islands_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a random islands graph with edges between the islands — add_islands_graph","text":"","code":"# Create a graph of islands islands_graph <- create_graph() %>% add_islands_graph( n_islands = 4, island_size = 10, p = 0.5, edges_between = 1, set_seed = 23) # Get a count of nodes islands_graph %>% count_nodes() #> [1] 40 # Get a count of edges islands_graph %>% count_edges() #> [1] 98"},{"path":"/reference/add_mathjax.html","id":null,"dir":"Reference","previous_headings":"","what":"Add MathJax-formatted equation text — add_mathjax","title":"Add MathJax-formatted equation text — add_mathjax","text":"Add MathJax-formatted equation text","code":""},{"path":"/reference/add_mathjax.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add MathJax-formatted equation text — add_mathjax","text":"","code":"add_mathjax(gv = NULL, include_mathjax = TRUE)"},{"path":"/reference/add_mathjax.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add MathJax-formatted equation text — add_mathjax","text":"gv grViz htmlwidget. include_mathjax logical add mathjax JS. Change FALSE using rmarkdown since MathJax likely already added.","code":""},{"path":"/reference/add_mathjax.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add MathJax-formatted equation text — add_mathjax","text":"grViz htmlwidget","code":""},{"path":"/reference/add_n_node_clones.html","id":null,"dir":"Reference","previous_headings":"","what":"Add one or several clones of an existing node to the graph — add_n_node_clones","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"Add n new nodes graph object class dgr_graph clones node already graph. node attributes preserved except node label attribute (maintain uniqueness non-NA node label values). vector node label can provided bind new labels cloned nodes.","code":""},{"path":"/reference/add_n_node_clones.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"","code":"add_n_node_clones(graph, n, node, label = NULL)"},{"path":"/reference/add_n_node_clones.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"graph graph object class dgr_graph. n number node clones add graph. node node ID corresponding graph node cloned. label optional vector node label values. vector length correspond value set n.","code":""},{"path":"/reference/add_n_node_clones.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_n_node_clones.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"","code":"# Create a graph with a path of # nodes; supply `label`, `type`, # and `value` node attributes graph <- create_graph() %>% add_path( n = 3, label = c(\"d\", \"g\", \"r\"), type = c(\"a\", \"b\", \"c\")) # Display the graph's internal # node data frame graph %>% get_node_df() #> id type label #> 1 1 a d #> 2 2 b g #> 3 3 c r # Create 3 clones of node `1` # but assign new node label # values (leaving `label` as # NULL yields NA values) graph <- graph %>% add_n_node_clones( n = 3, node = 1, label = c(\"x\", \"y\", \"z\")) # Display the graph's internal # node data frame: nodes `4`, # `5`, and `6` are clones of `1` graph %>% get_node_df() #> id type label #> 1 1 a d #> 2 2 b g #> 3 3 c r #> 4 4 a x #> 5 5 a y #> 6 6 a z"},{"path":"/reference/add_n_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Add one or several unconnected nodes to the graph — add_n_nodes","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"Add n new nodes graph object class dgr_graph. Optionally, set node type values new nodes.","code":""},{"path":"/reference/add_n_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"","code":"add_n_nodes( graph, n, type = NULL, label = NULL, node_aes = NULL, node_data = NULL )"},{"path":"/reference/add_n_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"graph graph object class dgr_graph. n number new nodes add graph. type optional character vector provides group identifiers nodes added. label optional character object describes nodes added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes.","code":""},{"path":"/reference/add_n_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_n_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"","code":"# Create an empty graph and # add 5 nodes; these nodes # will be assigned ID values # from `1` to `5` graph <- create_graph() %>% add_n_nodes(n = 5) # Get the graph's node IDs graph %>% get_node_ids() #> [1] 1 2 3 4 5"},{"path":"/reference/add_n_nodes_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"Add n new nodes one nodes available selection graph object class dgr_graph. New graph edges move either nodes selection toward newly created nodes (option direction = \"\"), selected nodes already graph (using direction = \"\"). Optionally, set node type edge rel values new nodes edges created, respectively. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/add_n_nodes_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"","code":"add_n_nodes_ws( graph, n, direction = NULL, type = NULL, label = NULL, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_n_nodes_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"graph graph object class dgr_graph. n number new nodes attach successor nodes nodes selection. direction Using create new edges existing nodes new nodes. option create new edges directed toward existing nodes. type optional character vector provides group identifiers nodes added. label optional character object describes nodes added. rel optional string apply rel attribute newly created edges. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_n_nodes_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_n_nodes_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"","code":"# Create an empty graph, add a node to it, select # that node, and then add 5 more nodes to the graph # with edges from the original node to all of the # new nodes graph <- create_graph() %>% add_n_nodes(n = 1) %>% select_last_nodes_created() %>% add_n_nodes_ws( n = 5, direction = \"from\") # Get the graph's nodes graph %>% get_node_ids() #> [1] 1 2 3 4 5 6 # Get the graph's edges graph %>% get_edges() #> [1] \"1->2\" \"1->3\" \"1->4\" \"1->5\" \"1->6\" # Create an empty graph, add a node to it, select # that node, and then add 5 more nodes to the graph # with edges toward the original node from all of # the new nodes graph <- create_graph() %>% add_n_nodes(n = 1) %>% select_last_nodes_created() %>% add_n_nodes_ws( n = 5, direction = \"to\") # Get the graph's nodes graph %>% get_node_ids() #> [1] 1 2 3 4 5 6 # Get the graph's edges graph %>% get_edges() #> [1] \"2->1\" \"3->1\" \"4->1\" \"5->1\" \"6->1\""},{"path":"/reference/add_node.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a node to an existing graph object — add_node","title":"Add a node to an existing graph object — add_node","text":"graph object class dgr_graph, add new node graph. One can optionally provide node attributes created node. also option create edges existing nodes graph. new edges can also created function, possibility set edge attributes new graph edges.","code":""},{"path":"/reference/add_node.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a node to an existing graph object — add_node","text":"","code":"add_node( graph, type = NULL, label = NULL, from = NULL, to = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_node.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a node to an existing graph object — add_node","text":"graph graph object class dgr_graph. type optional character object acts group identifier node added. label optional character object describes node. optional vector containing node IDs edges directed new node. optional vector containing node IDs edges directed new node. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_node.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a node to an existing graph object — add_node","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_node.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a node to an existing graph object — add_node","text":"","code":"# Create an empty graph and add 2 nodes by using # the `add_node()` function twice graph <- create_graph() %>% add_node() %>% add_node() # Get a count of all nodes # in the graph graph %>% count_nodes() #> [1] 2 # The nodes added were given # ID values `1` and `2`; obtain # the graph's node IDs graph %>% get_node_ids() #> [1] 1 2 # Add a node with a `type` # value defined graph <- graph %>% add_node(type = \"person\") # View the graph's internal # node data frame (ndf) graph %>% get_node_df() #> id type label #> 1 1 #> 2 2 #> 3 3 person "},{"path":"/reference/add_node_clones_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Add clones of a selection of nodes — add_node_clones_ws","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"Add new nodes graph object class dgr_graph clones nodes active selection nodes. node attributes preserved except node label attribute (maintain uniqueness non-NA node label values). vector node label can provided bind new labels cloned nodes. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/add_node_clones_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"","code":"add_node_clones_ws(graph, add_edges = FALSE, direction = NULL, label = NULL)"},{"path":"/reference/add_node_clones_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"graph graph object class dgr_graph. add_edges option whether add edges selected nodes clones, , opposite direction. direction Using create new edges existing nodes new, cloned nodes. option create new edges directed toward existing nodes. label optional vector node label values. vector length correspond number nodes active selection nodes.","code":""},{"path":"/reference/add_node_clones_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_node_clones_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"","code":"# Create a graph with a path of # nodes; supply `label`, `type`, # and `value` node attributes, # and select the created nodes graph <- create_graph() %>% add_path( n = 3, label = c(\"d\", \"g\", \"r\"), type = c(\"a\", \"b\", \"c\")) %>% select_last_nodes_created() # Display the graph's internal # node data frame graph %>% get_node_df() #> id type label #> 1 1 a d #> 2 2 b g #> 3 3 c r # Create clones of all nodes # in the selection but assign # new node label values # (leaving `label` as NULL # yields NA values) graph <- graph %>% add_node_clones_ws( label = c(\"a\", \"b\", \"v\")) # Display the graph's internal # node data frame: nodes `4`, # `5`, and `6` are clones of # `1`, `2`, and `3` graph %>% get_node_df() #> id type label #> 1 1 a d #> 2 2 b g #> 3 3 c r #> 4 4 a a #> 5 5 b b #> 6 6 c v # Select the last nodes # created (`4`, `5`, and `6`) # and clone those nodes and # their attributes while # creating new edges between # the new and existing nodes graph <- graph %>% select_last_nodes_created() %>% add_node_clones_ws( add_edges = TRUE, direction = \"to\", label = c(\"t\", \"z\", \"s\")) # Display the graph's internal # edge data frame; there are # edges between the selected # nodes and their clones graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 4 7 #> 4 4 5 8 #> 5 5 6 9 "},{"path":"/reference/add_node_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Add nodes from a node data frame to an existing graph object — add_node_df","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"graph object class dgr_graph add nodes node data frame graph.","code":""},{"path":"/reference/add_node_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"","code":"add_node_df(graph, node_df)"},{"path":"/reference/add_node_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"graph graph object class dgr_graph. node_df node data frame created using create_node_df().","code":""},{"path":"/reference/add_node_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_node_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"","code":"# Create an empty graph graph <- create_graph() # Create a node data frame (ndf) ndf <- create_node_df(n = 2) # Add the node data frame to # the graph object to create # a graph with nodes graph <- graph %>% add_node_df( node_df = ndf) # Inspect the graph's ndf graph %>% get_node_df() #> id type label #> 1 1 #> 2 2 # Create another ndf ndf_2 <- create_node_df(n = 3) # Add the second node data # frame to the graph object # to add more nodes with # attributes to the graph graph <- graph %>% add_node_df( node_df = ndf_2) # View the graph's internal # node data frame using the # `get_node_df()` function graph %>% get_node_df() #> id type label #> 1 1 #> 2 2 #> 3 3 #> 4 4 #> 5 5 "},{"path":"/reference/add_nodes_from_df_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"Add new nodes graph object class dgr_graph using distinct values one columns data frame. values serve node labels number nodes added depends number distinct values found specified columns.","code":""},{"path":"/reference/add_nodes_from_df_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"","code":"add_nodes_from_df_cols( graph, df, columns, type = NULL, keep_duplicates = FALSE )"},{"path":"/reference/add_nodes_from_df_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"graph graph object class dgr_graph. df data frame values taken new nodes graph. columns character vector column names numeric vector column numbers data frame supplied df. distinct values columns serve labels nodes added graph. type optional, single-length character vector provides group identifier nodes added graph. keep_duplicates option exclude incoming nodes labels (.e., values found columns specified df) match label values available graph's nodes. default, set FALSE.","code":""},{"path":"/reference/add_nodes_from_df_cols.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_nodes_from_df_cols.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"","code":"# Create an empty graph graph <- create_graph() # Create a data frame from # which several columns have # values designated as graph nodes df <- data.frame( col_1 = c(\"f\", \"p\", \"q\"), col_2 = c(\"q\", \"x\", \"f\"), col_3 = c(1, 5, 3), col_4 = c(\"a\", \"v\", \"h\"), stringsAsFactors = FALSE) # Add nodes from columns `col_1` # and `col_2` from the data frame # to the graph object graph <- graph %>% add_nodes_from_df_cols( df = df, columns = c(\"col_1\", \"col_2\")) # Show the graph's node data # frame; duplicate labels are # prevented with `keep_duplicates = # FALSE`) graph %>% get_node_df() #> id type label #> 1 1 f #> 2 2 p #> 3 3 q #> 4 4 x # Add new nodes from columns 3 and 4; # We can specify the columns by their # numbers as well graph <- graph %>% add_nodes_from_df_cols( df = df, columns = 3:4) # Show the graph's node data # frame; note that nodes didn't # get made with columns that # are not character class columns graph %>% get_node_df() #> id type label #> 1 1 f #> 2 2 p #> 3 3 q #> 4 4 x #> 5 5 a #> 6 6 v #> 7 7 h"},{"path":"/reference/add_nodes_from_table.html","id":null,"dir":"Reference","previous_headings":"","what":"Add nodes and attributes to graph from a table — add_nodes_from_table","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"Add nodes attributes existing graph object data CSV file data frame.","code":""},{"path":"/reference/add_nodes_from_table.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"","code":"add_nodes_from_table( graph, table, label_col = NULL, type_col = NULL, set_type = NULL, drop_cols = NULL )"},{"path":"/reference/add_nodes_from_table.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"graph graph object class dgr_graph. table Either path CSV file, , data frame object. label_col option apply column data table label attribute values. type_col option apply column data table type attribute values. set_type optional string apply type attribute nodes created data external table. drop_cols optional column selection statement dropping columns external table inclusion attributes graph's internal node data frame. Several columns can dropped name using syntax col_1 & col_2 & .... Columns can also dropped using numeric column range : (e.g., 5:8), , using : column names specify range (e.g., col_5_name:col_8_name).","code":""},{"path":"/reference/add_nodes_from_table.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_nodes_from_table.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"","code":"# To add nodes from the dataset called # `currencies` (available as a dataset # in the package), call the # `add_nodes_from_table()` function # after creating an empty graph; new # node ID values will be created as # monotonically-increasing values graph_1 <- create_graph() %>% add_nodes_from_table( table = currencies) # View part of the graph's internal # node data frame (ndf) graph_1 %>% get_node_df() %>% .[, 1:5] %>% head() #> id type label iso_4217_code curr_number #> 1 1 AED 784 #> 2 2 AFN 971 #> 3 3 ALL 8 #> 4 4 AMD 51 #> 5 5 ANG 532 #> 6 6 AOA 973 # If you would like to assign # any of the table's columns as # `type` or `label` attributes, # this can be done with the `type_col` # and `label_col` arguments; to set # a static `type` attribute for all # of the table records, use `set_type` graph_2 <- create_graph() %>% add_nodes_from_table( table = currencies, label_col = iso_4217_code, set_type = currency) # View part of the graph's internal ndf graph_2 %>% get_node_df() %>% .[, 1:5] %>% head() #> id type label curr_number exponent #> 1 1 currency AED 784 2 #> 2 2 currency AFN 971 2 #> 3 3 currency ALL 8 2 #> 4 4 currency AMD 51 2 #> 5 5 currency ANG 532 2 #> 6 6 currency AOA 973 2 # Suppose we would like to not # include certain columns from the # external table in the resulting # graph; we can use the `drop_cols` # argument to choose which columns # to not include as attributes graph_3 <- create_graph() %>% add_nodes_from_table( table = currencies, label_col = iso_4217_code, set_type = currency, drop_cols = exponent & currency_name) # Show the node attribute names # for the graph; note that the # `exponent` and `currency_name` # columns are not attributes in the # graph's internal node data frame graph_3 %>% get_node_df() %>% colnames() #> [1] \"id\" \"type\" \"label\" \"curr_number\""},{"path":"/reference/add_pa_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a preferential attachment graph — add_pa_graph","title":"Add a preferential attachment graph — add_pa_graph","text":"existing graph object, add graph built according Barabasi-Albert model, uses preferential attachment stochastic algorithm.","code":""},{"path":"/reference/add_pa_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a preferential attachment graph — add_pa_graph","text":"","code":"add_pa_graph( graph, n, m = NULL, power = 1, out_dist = NULL, use_total_degree = FALSE, zero_appeal = 1, algo = \"psumtree\", type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_pa_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a preferential attachment graph — add_pa_graph","text":"graph graph object class dgr_graph. n number nodes comprising preferential attachment graph. m number edges add time step. power power preferential attachment. default value 1 indicates linear preferential attachment. out_dist numeric vector provides distribution number edges add time step. use_total_degree logical value (default TRUE) governs whether total degree used calculating citation probability. FALSE, indegree used. zero_appeal measure attractiveness nodes adjacent edges. algo algorithm use generate graph. available options psumtree, psumtree-multiple, bag. psumtree algorithm, partial prefix-sum tree used create graph. values power zero_appeal can provided algorithm never generates multiple edges. psumtree-multiple algorithm also uses partial prefix-sum tree difference multiple edges allowed. bag algorithm places node IDs bag many times -degree (plus ). required number cited nodes drawn bag replacement. Multiple edges may produced using method (disallowed). type optional string describes entity type nodes added. label logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_pa_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a preferential attachment graph — add_pa_graph","text":"","code":"# Create an undirected PA # graph with 100 nodes, adding # 2 edges at every time step pa_graph <- create_graph( directed = FALSE) %>% add_pa_graph( n = 100, m = 1) # Get a count of nodes pa_graph %>% count_nodes() #> [1] 100 # Get a count of edges pa_graph %>% count_edges() #> [1] 99"},{"path":"/reference/add_path.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a path of nodes to the graph — add_path","title":"Add a path of nodes to the graph — add_path","text":"graph object class dgr_graph, add node path graph.","code":""},{"path":"/reference/add_path.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a path of nodes to the graph — add_path","text":"","code":"add_path( graph, n, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_path.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a path of nodes to the graph — add_path","text":"graph graph object class dgr_graph. n number nodes comprising path. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node path. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_path.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a path of nodes to the graph — add_path","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_path.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a path of nodes to the graph — add_path","text":"","code":"# Create a new graph and add # 2 paths of varying lengths graph <- create_graph() %>% add_path( n = 4, type = \"path\") %>% add_path( n = 5, type = \"path\") # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 path 1 1 0 1 0 #> 2 2 path 2 2 1 1 0 #> 3 3 path 3 2 1 1 0 #> 4 4 path 4 1 1 0 0 #> 5 5 path 5 1 0 1 0 #> 6 6 path 6 2 1 1 0 #> 7 7 path 7 2 1 1 0 #> 8 8 path 8 2 1 1 0 #> 9 9 path 9 1 1 0 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) graph_w_attrs <- create_graph() %>% add_path( n = 3, label = c( \"one\", \"two\", \"three\"), type = c( \"a\", \"a\", \"b\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), edge_aes = edge_aes( color = \"red\", penwidth = 1.2), node_data = node_data( value = c( 1.6, 2.8, 3.4)), edge_data = edge_data( value = rnorm( n = 2, mean = 5.0, sd = 1.0))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 a two steelblue 2.8 #> 3 3 b three steelblue 3.4 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 A 1.2 red 5.996605 #> 2 2 2 3 A 1.2 red 6.107490"},{"path":"/reference/add_prism.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a prism of nodes to the graph — add_prism","title":"Add a prism of nodes to the graph — add_prism","text":"graph object class dgr_graph, add node prism graph.","code":""},{"path":"/reference/add_prism.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a prism of nodes to the graph — add_prism","text":"","code":"add_prism( graph, n, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_prism.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a prism of nodes to the graph — add_prism","text":"graph graph object class dgr_graph. n number nodes describing shape prism. example, triangular prism n equal 3 composed 6 nodes 9 edges. n-gonal prism, graph generated 2n nodes 3n edges. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node prism. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_prism.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a prism of nodes to the graph — add_prism","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_prism.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a prism of nodes to the graph — add_prism","text":"","code":"# Create a new graph and # add 2 prisms graph <- create_graph() %>% add_prism( n = 3, type = \"prism\", label = \"a\") %>% add_prism( n = 3, type = \"prism\", label = \"b\") # Get node information from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 prism a 3 1 2 0 #> 2 2 prism a 3 1 2 0 #> 3 3 prism a 3 1 2 0 #> 4 4 prism a 3 2 1 0 #> 5 5 prism a 3 2 1 0 #> 6 6 prism a 3 2 1 0 #> 7 7 prism b 3 1 2 0 #> 8 8 prism b 3 1 2 0 #> 9 9 prism b 3 1 2 0 #> 10 10 prism b 3 2 1 0 #> 11 11 prism b 3 2 1 0 #> 12 12 prism b 3 2 1 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) graph_w_attrs <- create_graph() %>% add_prism( n = 3, label = c( \"one\", \"two\", \"three\", \"four\", \"five\", \"six\"), type = c( \"a\", \"a\", \"b\", \"b\", \"c\", \"c\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), edge_aes = edge_aes( color = \"red\", penwidth = 1.2), node_data = node_data( value = c( 1.6, 2.8, 3.4, 3.2, 5.3, 6.2)), edge_data = edge_data( value = rnorm( n = 9, mean = 5.0, sd = 1.0))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 a two steelblue 2.8 #> 3 3 b three steelblue 3.4 #> 4 4 b four steelblue 3.2 #> 5 5 c five steelblue 5.3 #> 6 6 c six steelblue 6.2 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 A 1.2 red 5.996605 #> 2 2 2 3 A 1.2 red 6.107490 #> 3 3 3 1 A 1.2 red 4.721914 #> 4 4 4 5 A 1.2 red 6.019205 #> 5 5 5 6 A 1.2 red 5.045437 #> 6 6 6 4 A 1.2 red 6.575780 #> 7 7 1 4 A 1.2 red 5.218288 #> 8 8 2 5 A 1.2 red 3.953465 #> 9 9 3 6 A 1.2 red 4.711311"},{"path":"/reference/add_reverse_edges_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"Add edges opposite direction one edges available edge selection graph object class dgr_graph. New graph edges opposite edge definitions selection. example, graph edge 1->2 active selection gain new 2->1 edge. also option assign common rel grouping newly created edges. Upon addition edges, edge selection retained selection traversal operations. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/add_reverse_edges_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"","code":"add_reverse_edges_ws(graph, rel = NULL, edge_aes = NULL, edge_data = NULL)"},{"path":"/reference/add_reverse_edges_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"graph graph object class dgr_graph. rel optional string apply rel attribute newly created edges. edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_reverse_edges_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_reverse_edges_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"","code":"# Create an empty graph, add 2 nodes to it, # and create the edge `1->2` graph <- create_graph() %>% add_n_nodes( n = 2, type = \"type_a\", label = c(\"a_1\", \"a_2\")) %>% add_edge( from = 1, to = 2, rel = \"a\") # Get the graph's edges graph %>% get_edge_ids() #> [1] 1 # Select the edge and create 2 additional edges # with the opposite definition of `1->2`, which # is `2->1`; also, apply, different `rel` values # (`b` and `c`) graph <- graph %>% select_edges() %>% add_reverse_edges_ws(rel = \"b\") %>% add_reverse_edges_ws(rel = \"c\") %>% clear_selection() # Get the graph's edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 a #> 2 2 2 1 b #> 3 3 2 1 c"},{"path":"/reference/add_smallworld_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"existing graph object, add graph built according Watts-Strogatz small-world model, uses lattice along rewiring probability randomly modify edge definitions.","code":""},{"path":"/reference/add_smallworld_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"","code":"add_smallworld_graph( graph, dimension, size, neighborhood, p, loops = FALSE, multiple = FALSE, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_smallworld_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"graph graph object class dgr_graph. dimension dimension starting lattice. size size lattice across dimension. neighborhood neighborhood lattice nodes connected. p rewiring probability. loops logical value (default FALSE) governs whether loops allowed created. multiple logical value (default FALSE) governs whether multiple edges allowed created. type optional string describes entity type nodes added. label logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_smallworld_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_smallworld_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"","code":"# Create an undirected smallworld # graph with 100 nodes using # a probability value of 0.05 smallworld_graph <- create_graph( directed = FALSE) %>% add_smallworld_graph( dimension = 1, size = 50, neighborhood = 1, p = 0.05, set_seed = 23) # Get a count of nodes smallworld_graph %>% count_nodes() #> [1] 50 # Get a count of edges smallworld_graph %>% count_edges() #> [1] 50"},{"path":"/reference/add_star.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a star of nodes to the graph — add_star","title":"Add a star of nodes to the graph — add_star","text":"graph object class dgr_graph, add node star graph.","code":""},{"path":"/reference/add_star.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a star of nodes to the graph — add_star","text":"","code":"add_star( graph, n, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_star.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a star of nodes to the graph — add_star","text":"graph graph object class dgr_graph. n number nodes comprising star. first node center star. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node star. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_star.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a star of nodes to the graph — add_star","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_star.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a star of nodes to the graph — add_star","text":"","code":"# Create a new graph and add 2 # stars of varying numbers of nodes graph <- create_graph() %>% add_star( n = 4, type = \"four_star\") %>% add_star( n = 5, type = \"five_star\") # Get node information from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 four_star 1 3 0 3 0 #> 2 2 four_star 2 1 1 0 0 #> 3 3 four_star 3 1 1 0 0 #> 4 4 four_star 4 1 1 0 0 #> 5 5 five_star 5 4 0 4 0 #> 6 6 five_star 6 1 1 0 0 #> 7 7 five_star 7 1 1 0 0 #> 8 8 five_star 8 1 1 0 0 #> 9 9 five_star 9 1 1 0 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) graph_w_attrs <- create_graph() %>% add_star( n = 4, label = c( \"one\", \"two\", \"three\", \"four\"), type = c( \"a\", \"a\", \"b\", \"b\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), edge_aes = edge_aes( color = \"red\", penwidth = 1.2), node_data = node_data( value = c( 1.6, 2.8, 3.4, 8.3)), edge_data = edge_data( value = rnorm( n = 3, mean = 5.0, sd = 1.0))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 a two steelblue 2.8 #> 3 3 b three steelblue 3.4 #> 4 4 b four steelblue 8.3 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 A 1.2 red 5.996605 #> 2 2 1 3 A 1.2 red 6.107490 #> 3 3 1 4 A 1.2 red 4.721914"},{"path":"/reference/clear_selection.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear an active selection of nodes or edges — clear_selection","title":"Clear an active selection of nodes or edges — clear_selection","text":"Clear selection nodes edges within graph object.","code":""},{"path":"/reference/clear_selection.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear an active selection of nodes or edges — clear_selection","text":"","code":"clear_selection(graph)"},{"path":"/reference/clear_selection.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear an active selection of nodes or edges — clear_selection","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/clear_selection.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear an active selection of nodes or edges — clear_selection","text":"graph object class dgr_graph.","code":""},{"path":"/reference/clear_selection.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Clear an active selection of nodes or edges — clear_selection","text":"","code":"# Create a graph with # a single path graph <- create_graph() %>% add_path(n = 5) # Select nodes with IDs `1` # and `3` graph <- graph %>% select_nodes( nodes = c(1, 3)) # Verify that a node selection # has been made graph %>% get_selection() #> [1] 1 3 # Clear the selection with # `clear_selection()` graph <- graph %>% clear_selection() # Verify that the node # selection has been cleared graph %>% get_selection() #> [1] NA"},{"path":"/reference/colorize_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply colors based on edge attribute values — colorize_edge_attrs","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"Within graph's internal edge data frame (edf), use categorical edge attribute generate new edge attribute color values.","code":""},{"path":"/reference/colorize_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"","code":"colorize_edge_attrs( graph, edge_attr_from, edge_attr_to, cut_points = NULL, palette = \"Spectral\", alpha = NULL, reverse_palette = FALSE, default_color = \"#D9D9D9\" )"},{"path":"/reference/colorize_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from name edge attribute column color values based. edge_attr_to name new edge attribute color values applied. cut_points optional vector numerical breaks bucketizing continuous numerical values available edge attribute column. palette Can either : (1) palette name RColorBrewer package (e.g., Greens, OrRd, RdYlGn), (2) viridis, indicates use viridis color scale package name, (3) vector hexadecimal color names. alpha optional alpha transparency value apply generated colors. range 0 (completely transparent) 100 (completely opaque). reverse_palette option reverse order colors chosen palette. default FALSE. default_color hexadecimal color value use instances values fall bucket ranges specified cut_points vector.","code":""},{"path":"/reference/colorize_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":"/reference/colorize_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"","code":"# Create a graph with 5 # nodes and 4 edges graph <- create_graph() %>% add_path(n = 5) %>% set_edge_attrs( edge_attr = weight, values = c(3.7, 6.3, 9.2, 1.6)) # We can bucketize values in # the edge `weight` attribute using # `cut_points` and, by doing so, # assign colors to each of the # bucketed ranges (for values not # part of any bucket, a gray color # is assigned by default) graph <- graph %>% colorize_edge_attrs( edge_attr_from = weight, edge_attr_to = color, cut_points = c(0, 2, 4, 6, 8, 10), palette = \"RdYlGn\") # Now there will be a `color` # edge attribute with distinct # colors (from the RColorBrewer # Red-Yellow-Green palette) graph %>% get_edge_df() #> id from to rel weight color #> 1 1 1 2 3.7 #FDAE61 #> 2 2 2 3 6.3 #A6D96A #> 3 3 3 4 9.2 #1A9641 #> 4 4 4 5 1.6 #D7191C"},{"path":"/reference/colorize_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply colors based on node attribute values — colorize_node_attrs","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"Within graph's internal node data frame (ndf), use categorical node attribute generate new node attribute color values.","code":""},{"path":"/reference/colorize_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"","code":"colorize_node_attrs( graph, node_attr_from, node_attr_to, cut_points = NULL, palette = \"Spectral\", alpha = NULL, reverse_palette = FALSE, default_color = \"#D9D9D9\" )"},{"path":"/reference/colorize_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"graph graph object class dgr_graph. node_attr_from name node attribute column color values based. node_attr_to name new node attribute color values applied. cut_points optional vector numerical breaks bucketizing continuous numerical values available edge attribute column. palette Can either : (1) palette name RColorBrewer package (e.g., Greens, OrRd, RdYlGn), (2) viridis, indicates use viridis color scale package name, (3) vector hexadecimal color names. alpha optional alpha transparency value apply generated colors. range 0 (completely transparent) 100 (completely opaque). reverse_palette option reverse order colors chosen palette. default FALSE. default_color hexadecimal color value use instances values fall bucket ranges specified cut_points vector.","code":""},{"path":"/reference/colorize_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/colorize_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"","code":"# Create a graph with 8 # nodes and 7 edges graph <- create_graph() %>% add_path(n = 8) %>% set_node_attrs( node_attr = weight, values = c( 8.2, 3.7, 6.3, 9.2, 1.6, 2.5, 7.2, 5.4)) # Find group membership values for all nodes # in the graph through the Walktrap community # finding algorithm and join those group values # to the graph's internal node data frame (ndf) # with the `join_node_attrs()` function graph <- graph %>% join_node_attrs( df = get_cmty_walktrap(.)) # Inspect the number of distinct communities graph %>% get_node_attrs( node_attr = walktrap_group) %>% unique() %>% sort() #> [1] 1 2 3 # Visually distinguish the nodes in the different # communities by applying colors using the # `colorize_node_attrs()` function; specifically, # set different `fillcolor` values with an alpha # value of 90 and apply opaque colors to the node # border (with the `color` node attribute) graph <- graph %>% colorize_node_attrs( node_attr_from = walktrap_group, node_attr_to = fillcolor, palette = \"Greens\", alpha = 90) %>% colorize_node_attrs( node_attr_from = walktrap_group, node_attr_to = color, palette = \"viridis\", alpha = 80) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label weight walktrap_group fillcolor color #> 1 1 1 8.2 2 #A1D99B90 #21908C80 #> 2 2 2 3.7 2 #A1D99B90 #21908C80 #> 3 3 3 6.3 2 #A1D99B90 #21908C80 #> 4 4 4 9.2 3 #31A35490 #FDE72580 #> 5 5 5 1.6 3 #31A35490 #FDE72580 #> 6 6 6 2.5 1 #E5F5E090 #44015480 #> 7 7 7 7.2 1 #E5F5E090 #44015480 #> 8 8 8 5.4 1 #E5F5E090 #44015480 # Create a graph with 8 nodes and 7 edges graph <- create_graph() %>% add_path(n = 8) %>% set_node_attrs( node_attr = weight, values = c( 8.2, 3.7, 6.3, 9.2, 1.6, 2.5, 7.2, 5.4)) # We can bucketize values in `weight` using # `cut_points` and assign colors to each of the # bucketed ranges (for values not part of any # bucket, a gray color is assigned by default) graph <- graph %>% colorize_node_attrs( node_attr_from = weight, node_attr_to = fillcolor, cut_points = c(1, 3, 5, 7, 9)) # Now there will be a `fillcolor` node attribute # with distinct colors (the `#D9D9D9` color is # the default `gray85` color) graph %>% get_node_df() #> id type label weight fillcolor #> 1 1 1 8.2 #2B83BA #> 2 2 2 3.7 #FDAE61 #> 3 3 3 6.3 #ABDDA4 #> 4 4 4 9.2 #D9D9D9 #> 5 5 5 1.6 #D7191C #> 6 6 6 2.5 #D7191C #> 7 7 7 7.2 #2B83BA #> 8 8 8 5.4 #ABDDA4"},{"path":"/reference/combine_edfs.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine multiple edge data frames into a single edge data frame — combine_edfs","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"Combine several edge data frames style rbind(), except, works regardless number ordering columns.","code":""},{"path":"/reference/combine_edfs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"","code":"combine_edfs(...)"},{"path":"/reference/combine_edfs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"... Two edge data frames, contain edge IDs associated attributes.","code":""},{"path":"/reference/combine_edfs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"combined edge data frame.","code":""},{"path":"/reference/combine_edfs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"","code":"# Create an edge data frame (edf) edf_1 <- create_edge_df( from = c(1, 1, 2, 3), to = c(2, 4, 4, 1), rel = \"requires\", color = \"green\", data = c(2.7, 8.9, 2.6, 0.6)) # Create a second edge data frame edf_2 <- create_edge_df( from = c(5, 7, 8, 8), to = c(7, 8, 6, 5), rel = \"receives\", arrowhead = \"dot\", color = \"red\") # Combine the two edge data frames all_edges <- combine_edfs(edf_1, edf_2) # View the combined edge data frame all_edges #> id from to rel color data arrowhead #> 1 1 1 2 requires green 2.7 #> 2 2 1 4 requires green 8.9 #> 3 3 2 4 requires green 2.6 #> 4 4 3 1 requires green 0.6 #> 5 5 5 7 receives red NA dot #> 6 6 7 8 receives red NA dot #> 7 7 8 6 receives red NA dot #> 8 8 8 5 receives red NA dot"},{"path":"/reference/combine_graphs.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine two graphs into a single graph — combine_graphs","title":"Combine two graphs into a single graph — combine_graphs","text":"Combine two graphs order make new graph.","code":""},{"path":"/reference/combine_graphs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine two graphs into a single graph — combine_graphs","text":"","code":"combine_graphs(x, y)"},{"path":"/reference/combine_graphs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine two graphs into a single graph — combine_graphs","text":"x DiagrammeR graph object another graph unioned. graph considered graph global graph attributes inherited resulting graph. y DiagrammeR graph object unioned graph supplied x.","code":""},{"path":"/reference/combine_graphs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine two graphs into a single graph — combine_graphs","text":"graph object class dgr_graph.","code":""},{"path":"/reference/combine_graphs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine two graphs into a single graph — combine_graphs","text":"","code":"# Create a graph with a cycle # containing 6 nodes graph_cycle <- create_graph() %>% add_cycle(n = 6) # Create a random graph with # 8 nodes and 15 edges using the # `add_gnm_graph()` function graph_random <- create_graph() %>% add_gnm_graph( n = 8, m = 15, set_seed = 23) # Combine the two graphs in a # union operation combined_graph <- combine_graphs( graph_cycle, graph_random) # Get the number of nodes in # the combined graph combined_graph %>% count_nodes() #> [1] 14 # The `combine_graphs()` # function will renumber # node ID values in graph `y` # during the union; this ensures # that node ID values are unique combined_graph %>% get_node_ids() #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14"},{"path":"/reference/combine_ndfs.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine multiple node data frames — combine_ndfs","title":"Combine multiple node data frames — combine_ndfs","text":"Combine several node data frames single node data frame.","code":""},{"path":"/reference/combine_ndfs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine multiple node data frames — combine_ndfs","text":"","code":"combine_ndfs(...)"},{"path":"/reference/combine_ndfs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine multiple node data frames — combine_ndfs","text":"... Two node data frames, contain node IDs associated attributes.","code":""},{"path":"/reference/combine_ndfs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine multiple node data frames — combine_ndfs","text":"combined node data frame.","code":""},{"path":"/reference/combine_ndfs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine multiple node data frames — combine_ndfs","text":"","code":"# Create two node data frames node_df_1 <- create_node_df( n = 2, type = c(\"a\", \"b\"), label = c(\"D\", \"Z\"), value = c(8.4, 3.4)) node_df_2 <- create_node_df( n = 2, type = c(\"b\", \"c\"), label = c(\"U\", \"A\"), value = c(0.4, 3.4)) # Combine the ndfs using the # `combine_ndfs()` function node_df_combined <- combine_ndfs( node_df_1, node_df_2) # Inspect the combined ndf node_df_combined #> id type label value #> 1 1 a D 8.4 #> 2 2 b Z 3.4 #> 3 3 b U 0.4 #> 4 4 c A 3.4"},{"path":"/reference/copy_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Copy an edge attribute column and set the name — copy_edge_attrs","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"Within graph's internal edge data frame (edf), copy contents existing edge attribute create distinct edge attribute within edf different attribute name.","code":""},{"path":"/reference/copy_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"","code":"copy_edge_attrs(graph, edge_attr_from, edge_attr_to)"},{"path":"/reference/copy_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from name edge attribute column values copied. edge_attr_to name new edge attribute column copied values placed.","code":""},{"path":"/reference/copy_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/copy_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 8, set_seed = 23) %>% set_edge_attrs( edge_attr = color, values = \"green\") # Get the graph's internal # edf to show which edge # attributes are available graph %>% get_edge_df() #> id from to rel color #> 1 1 1 3 green #> 2 2 2 1 green #> 3 3 2 5 green #> 4 4 2 3 green #> 5 5 3 2 green #> 6 6 3 5 green #> 7 7 3 4 green #> 8 8 5 3 green # Make a copy the `color` # edge attribute as the # `color_2` edge attribute graph <- graph %>% copy_edge_attrs( edge_attr_from = color, edge_attr_to = color_2) # Get the graph's internal # edf to show that the edge # attribute had been copied graph %>% get_edge_df() #> id from to rel color color_2 #> 1 1 1 3 green green #> 2 2 2 1 green green #> 3 3 2 5 green green #> 4 4 2 3 green green #> 5 5 3 2 green green #> 6 6 3 5 green green #> 7 7 3 4 green green #> 8 8 5 3 green green"},{"path":"/reference/copy_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Copy a node attribute column and set the name — copy_node_attrs","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"Within graph's internal node data frame (ndf), copy contents existing node attribute create distinct node attribute within ndf different attribute name.","code":""},{"path":"/reference/copy_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"","code":"copy_node_attrs(graph, node_attr_from, node_attr_to)"},{"path":"/reference/copy_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"graph graph object class dgr_graph. node_attr_from name node attribute column values copied. node_attr_to name new node attribute column copied values placed.","code":""},{"path":"/reference/copy_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/copy_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) %>% set_node_attrs( node_attr = shape, values = \"circle\") %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the graph's internal # ndf to show which node # attributes are available graph %>% get_node_df() #> id type label shape value #> 1 1 1 circle 5.3 #> 2 2 2 circle 4.4 #> 3 3 3 circle 5.8 #> 4 4 4 circle 5.9 #> 5 5 5 circle 6.2 # Make a copy the `value` # node attribute as the # `width` node attribute graph <- graph %>% copy_node_attrs( node_attr_from = value, node_attr_to = size) # Get the graph's internal # ndf to show that the node # attribute had been copied graph %>% get_node_df() #> id type label shape value size #> 1 1 1 circle 5.3 5.3 #> 2 2 2 circle 4.4 4.4 #> 3 3 3 circle 5.8 5.8 #> 4 4 4 circle 5.9 5.9 #> 5 5 5 circle 6.2 6.2"},{"path":"/reference/count_asymmetric_node_pairs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"Get number asymmetrically-connected node pairs. works directed graphs.","code":""},{"path":"/reference/count_asymmetric_node_pairs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"","code":"count_asymmetric_node_pairs(graph)"},{"path":"/reference/count_asymmetric_node_pairs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_asymmetric_node_pairs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"single numeric value representing number asymmetrically-connected node pairs.","code":""},{"path":"/reference/count_asymmetric_node_pairs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Get a count of asymmetrically- # connected node pairs graph %>% count_asymmetric_node_pairs() #> [1] 5 # Create a full graph and then # count the asymmetrically- # connected node pairs create_graph() %>% add_full_graph(n = 10) %>% count_asymmetric_node_pairs() #> [1] 0"},{"path":"/reference/count_automorphisms.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of automorphisms — count_automorphisms","title":"Get the number of automorphisms — count_automorphisms","text":"Get number automorphisms graph contains. automorphism graph form symmetry graph mapped onto preserving edge-node connectivity.","code":""},{"path":"/reference/count_automorphisms.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of automorphisms — count_automorphisms","text":"","code":"count_automorphisms(graph)"},{"path":"/reference/count_automorphisms.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of automorphisms — count_automorphisms","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_automorphisms.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of automorphisms — count_automorphisms","text":"single numeric value representing number automorphisms graph contains.","code":""},{"path":"/reference/count_automorphisms.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of automorphisms — count_automorphisms","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Get a count of automorphisms graph %>% count_automorphisms() #> [1] 10 # Create a full graph and then # count the automorphisms create_graph() %>% add_full_graph(n = 10) %>% count_automorphisms() #> [1] 3628800"},{"path":"/reference/count_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a count of all edges — count_edges","title":"Get a count of all edges — count_edges","text":"graph object class dgr_graph, get count edges graph.","code":""},{"path":"/reference/count_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a count of all edges — count_edges","text":"","code":"count_edges(graph)"},{"path":"/reference/count_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a count of all edges — count_edges","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a count of all edges — count_edges","text":"single-length numeric vector.","code":""},{"path":"/reference/count_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a count of all edges — count_edges","text":"","code":"# Create a graph with a # path of nodes and 3 # unconnected nodes graph <- create_graph() %>% add_path(n = 3) %>% add_n_nodes(n = 3) # Get a count of all edges # in the graph graph %>% count_edges() #> [1] 2"},{"path":"/reference/count_graphs_in_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Count graphs in a graph series object — count_graphs_in_graph_series","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"Counts total number graphs graph series object.","code":""},{"path":"/reference/count_graphs_in_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"","code":"count_graphs_in_graph_series(graph_series)"},{"path":"/reference/count_graphs_in_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"graph_series graph series object type dgr_graph_1D","code":""},{"path":"/reference/count_graphs_in_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"numeric vector representing count graphs graph series object.","code":""},{"path":"/reference/count_graphs_in_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Count the number of graphs # in the graph series series %>% count_graphs_in_graph_series() #> [1] 3"},{"path":"/reference/count_loop_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Get count of all loop edges — count_loop_edges","title":"Get count of all loop edges — count_loop_edges","text":"graph object class dgr_graph, get count loop edges graph.","code":""},{"path":"/reference/count_loop_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get count of all loop edges — count_loop_edges","text":"","code":"count_loop_edges(graph)"},{"path":"/reference/count_loop_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get count of all loop edges — count_loop_edges","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_loop_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get count of all loop edges — count_loop_edges","text":"numeric vector single length.","code":""},{"path":"/reference/count_loop_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get count of all loop edges — count_loop_edges","text":"","code":"# Create an undirected, full graph # with 3 nodes and all possible # edges, including loop edges graph <- create_graph( directed = FALSE) %>% add_full_graph( n = 3, keep_loops = TRUE) # Get a count of all loop edges # in the graph graph %>% count_loop_edges() #> [1] 3"},{"path":"/reference/count_mutual_node_pairs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"Get number mutually-connected node pairs. works directed graphs.","code":""},{"path":"/reference/count_mutual_node_pairs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"","code":"count_mutual_node_pairs(graph)"},{"path":"/reference/count_mutual_node_pairs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_mutual_node_pairs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"single numeric value representing number mutually-connected node pairs.","code":""},{"path":"/reference/count_mutual_node_pairs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Get a count of mutually-connected # node pairs graph %>% count_mutual_node_pairs() #> [1] 0 # Create a full graph and then # count the mutually-connected # node pairs create_graph() %>% add_full_graph(n = 10) %>% count_mutual_node_pairs() #> [1] 45"},{"path":"/reference/count_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a count of all nodes — count_nodes","title":"Get a count of all nodes — count_nodes","text":"graph object class dgr_graph, get count nodes graph.","code":""},{"path":"/reference/count_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a count of all nodes — count_nodes","text":"","code":"count_nodes(graph)"},{"path":"/reference/count_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a count of all nodes — count_nodes","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a count of all nodes — count_nodes","text":"numeric vector single length.","code":""},{"path":"/reference/count_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a count of all nodes — count_nodes","text":"","code":"# Create a graph with a # path of nodes and 3 # unconnected nodes graph <- create_graph() %>% add_path(n = 3) %>% add_n_nodes(n = 3) # Get a count of all nodes # in the graph graph %>% count_nodes() #> [1] 6"},{"path":"/reference/count_s_connected_cmpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of strongly-connected components — count_s_connected_cmpts","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"Get number strongly-connected components graph.","code":""},{"path":"/reference/count_s_connected_cmpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"","code":"count_s_connected_cmpts(graph)"},{"path":"/reference/count_s_connected_cmpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_s_connected_cmpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"single integer value representing number strongly-connected graph components.","code":""},{"path":"/reference/count_s_connected_cmpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"","code":"# Create a graph and add # several graph islands graph <- create_graph() %>% add_islands_graph( n_islands = 4, island_size = 10, p = 1/5, edges_between = 1, set_seed = 23) # Get a count of strongly-connected # components in the graph graph %>% count_s_connected_cmpts() #> [1] 4"},{"path":"/reference/count_unconnected_node_pairs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of unconnected node pairs — count_unconnected_node_pairs","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"Get number unconnected node pairs. works directed graphs.","code":""},{"path":"/reference/count_unconnected_node_pairs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"","code":"count_unconnected_node_pairs(graph)"},{"path":"/reference/count_unconnected_node_pairs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_unconnected_node_pairs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"single numeric value representing number unconnected node pairs.","code":""},{"path":"/reference/count_unconnected_node_pairs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Get a count of unconnected node # pairs in the graph graph %>% count_unconnected_node_pairs() #> [1] 5 # Create a full graph and then # count all unconnected node pairs create_graph() %>% add_full_graph(n = 10) %>% count_unconnected_node_pairs() #> [1] 0"},{"path":"/reference/count_unconnected_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Get count of all unconnected nodes — count_unconnected_nodes","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"graph object class dgr_graph, get count nodes graph connected node.","code":""},{"path":"/reference/count_unconnected_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"","code":"count_unconnected_nodes(graph)"},{"path":"/reference/count_unconnected_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_unconnected_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"numeric vector single length.","code":""},{"path":"/reference/count_unconnected_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"","code":"# Create a graph with a # path of nodes and 3 # unconnected nodes graph <- create_graph() %>% add_path(n = 3) %>% add_n_nodes(n = 3) # Get a count of all nodes # in the graph graph %>% count_nodes() #> [1] 6 # Get a count of all # unconnected nodes in the # graph graph %>% count_unconnected_nodes() #> [1] 3"},{"path":"/reference/count_w_connected_cmpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of weakly-connected components — count_w_connected_cmpts","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"Get number weakly-connected components graph.","code":""},{"path":"/reference/count_w_connected_cmpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"","code":"count_w_connected_cmpts(graph)"},{"path":"/reference/count_w_connected_cmpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_w_connected_cmpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"single integer value representing number weakly-connected graph components.","code":""},{"path":"/reference/count_w_connected_cmpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) %>% add_cycle(n = 5) # Get a count of weakly-connected # components in the graph graph %>% count_w_connected_cmpts() #> [1] 2"},{"path":"/reference/create_edge_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an edge data frame — create_edge_df","title":"Create an edge data frame — create_edge_df","text":"Combine several vectors edges attributes data frame, can combined similarly-generated data frames, , added graph object. edge data frame, edf, least following columns: id (type integer) (type integer) (type integer) rel (type character) arbitrary number additional columns containing aesthetic data attributes can part edf, long follow aforementioned columns.","code":""},{"path":"/reference/create_edge_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an edge data frame — create_edge_df","text":"","code":"create_edge_df(from, to, rel = NULL, ...)"},{"path":"/reference/create_edge_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an edge data frame — create_edge_df","text":"vector node ID values edges outbound. vector length must equal vector. vector node ID values edges incoming. vector length must equal vector. rel optional rel label edge. ... One vectors associated edge attributes.","code":""},{"path":"/reference/create_edge_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an edge data frame — create_edge_df","text":"edge data frame (edf).","code":""},{"path":[]},{"path":"/reference/create_edge_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an edge data frame — create_edge_df","text":"","code":"# Create a simple edge data frame (edf) and # view the results edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"a\") # Display the edge data frame edf #> id from to rel #> 1 1 1 4 a #> 2 2 2 3 a #> 3 3 3 1 a # Create an edf with additional edge # attributes (where their classes will # be inferred from the input vectors) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"a\", length = c(50, 100, 250), color = \"green\", width = c(1, 5, 2)) # Display the edge data frame edf #> id from to rel length color width #> 1 1 1 4 a 50 green 1 #> 2 2 2 3 a 100 green 5 #> 3 3 3 1 a 250 green 2"},{"path":"/reference/create_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a graph object — create_graph","title":"Create a graph object — create_graph","text":"Generates graph object option use node data frames (ndfs) /edge data frames (edfs) populate initial graph.","code":""},{"path":"/reference/create_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a graph object — create_graph","text":"","code":"create_graph( nodes_df = NULL, edges_df = NULL, directed = TRUE, graph_name = NULL, attr_theme = \"default\", write_backups = FALSE, display_msgs = FALSE )"},{"path":"/reference/create_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a graph object — create_graph","text":"nodes_df optional data frame containing, minimum, column (called id) contains node IDs graph. Additional columns (node attributes) can included values named node attribute. edges_df optional data frame containing, minimum, two columns (called ) node IDs provided. Additional columns (edge attributes) can included values named edge attribute. directed TRUE (default) FALSE, either directed undirected edge operations generated, respectively. graph_name optional string labeling graph object. attr_theme theme (.e., collection graph, node, edge global graph attributes) use graph. default theme called default; hierarchical layout themes called lr, tb, rl, bt (operate left--right, top--bottom, right--left, bottom--top); , larger graphs, fdp theme provides force directed layout. set NULL global graph attributes applied graph upon creation. write_backups option write incremental backups changing graph states disk. TRUE, subdirectory within working directory created used store RDS files. default value FALSE one opt use functionality. display_msgs option display messages primarily concerned changes graph selections. default, FALSE.","code":""},{"path":"/reference/create_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a graph object — create_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/create_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a graph object — create_graph","text":"","code":"# With `create_graph()` we can # simply create an empty graph (and # add in nodes and edges later # with other functions) graph <- create_graph() # A graph can be created with # nodes and without having any edges; # this can be done in 2 steps: # 1. create a node data frame (ndf) # using `create_node_df()` ndf <- create_node_df(n = 4) # 2. create a new graph object with # `create_graph()` and then pass # in the ndf to `nodes_df` graph <- create_graph( nodes_df = ndf) # Get information on the graph's nodes graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 0 0 0 0 #> 2 2 0 0 0 0 #> 3 3 0 0 0 0 #> 4 4 0 0 0 0 # You can create a similar graph with # just nodes but also providing a # range of attributes for the nodes # (e.g., types, labels, or arbitrary # 'values') ndf <- create_node_df( n = 4, label = TRUE, type = c(\"type_1\", \"type_1\", \"type_5\", \"type_2\"), shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), values = c(3.5, 2.6, 9.4, 2.7)) graph <- create_graph(nodes_df = ndf) # Get information on the graph's # internal node data frame (ndf) graph %>% get_node_df() #> id type label shape values #> 1 1 type_1 1 circle 3.5 #> 2 2 type_1 2 circle 2.6 #> 3 3 type_5 3 rectangle 9.4 #> 4 4 type_2 4 rectangle 2.7 # A graph can also be created by # specifying both the nodes and # edges; create an edge data frame # (edf) using the `create_edge_df()` # function: edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\", values = c(7.3, 2.6, 8.3)) # Create the graph object with # `create_graph()` and pass in the # ndf and edf objects graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get information on the graph's # internal edge data frame (edf) graph %>% get_edge_df() #> id from to rel values #> 1 1 1 4 leading_to 7.3 #> 2 2 2 3 leading_to 2.6 #> 3 3 3 1 leading_to 8.3 # Get information on the graph's # internal node data frame (ndf) graph %>% get_node_df() #> id type label shape values #> 1 1 type_1 1 circle 3.5 #> 2 2 type_1 2 circle 2.6 #> 3 3 type_5 3 rectangle 9.4 #> 4 4 type_2 4 rectangle 2.7"},{"path":"/reference/create_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a graph series object — create_graph_series","title":"Create a graph series object — create_graph_series","text":"Create graph series object storage multiple graphs across sequential temporal one-dimensional array.","code":""},{"path":"/reference/create_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a graph series object — create_graph_series","text":"","code":"create_graph_series( graph = NULL, series_name = NULL, series_type = \"sequential\" )"},{"path":"/reference/create_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a graph series object — create_graph_series","text":"graph graph object add new graph series object. series_name optional name ascribe series. series_type Either sequential type (default) temporal type (requires date-time strings time zone codes supplied).","code":""},{"path":"/reference/create_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a graph series object — create_graph_series","text":"graph series object type dgr_graph_1D.","code":""},{"path":"/reference/create_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a graph series object — create_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Count the number of graphs # in the graph series series %>% count_graphs_in_graph_series() #> [1] 3"},{"path":"/reference/create_node_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a node data frame — create_node_df","title":"Create a node data frame — create_node_df","text":"Combine several vectors nodes attributes data frame, can combined similarly-generated data frames, , added graph object. node data frame, ndf, least following columns: id (type integer) type (type character) label (type character) arbitrary number additional columns containing aesthetic data attributes can part ndf, long follow aforementioned columns.","code":""},{"path":"/reference/create_node_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a node data frame — create_node_df","text":"","code":"create_node_df(n, type = NULL, label = NULL, ...)"},{"path":"/reference/create_node_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a node data frame — create_node_df","text":"n total number nodes include node data frame. type optional type node. label optional label node. ... One vectors associated node attributes.","code":""},{"path":"/reference/create_node_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a node data frame — create_node_df","text":"node data frame (ndf).","code":""},{"path":[]},{"path":"/reference/create_node_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a node data frame — create_node_df","text":"","code":"# Create a node data frame (ndf) where the labels # are equivalent to the node ID values (this is not # recommended); the `label` and `type` node # attributes will always be a `character` class # whereas `id` will always be an `integer` node_df <- create_node_df( n = 4, type = c(\"a\", \"a\", \"b\", \"b\"), label = TRUE) # Display the node data frame node_df #> id type label #> 1 1 a 1 #> 2 2 a 2 #> 3 3 b 3 #> 4 4 b 4 # Create an ndf with distinct labels and # additional node attributes (where their classes # will be inferred from the input vectors) node_df <- create_node_df( n = 4, type = \"a\", label = c(2384, 3942, 8362, 2194), style = \"filled\", color = \"aqua\", shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), value = c(3.5, 2.6, 9.4, 2.7)) # Display the node data frame node_df #> id type label style color shape value #> 1 1 a 2384 filled aqua circle 3.5 #> 2 2 a 3942 filled aqua circle 2.6 #> 3 3 a 8362 filled aqua rectangle 9.4 #> 4 4 a 2194 filled aqua rectangle 2.7"},{"path":"/reference/currencies.html","id":null,"dir":"Reference","previous_headings":"","what":"ISO-4217 currency data. — currencies","title":"ISO-4217 currency data. — currencies","text":"dataset containing currency information ISO-4217 standard.","code":""},{"path":"/reference/currencies.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ISO-4217 currency data. — currencies","text":"","code":"currencies"},{"path":"/reference/currencies.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ISO-4217 currency data. — currencies","text":"data frame 171 rows 4 variables: iso_4217_code three-letter currency code according ISO-4217 standard curr_number three-digit code number assigned currency ISO-4217 standard exponent base 10 exponent minor currency unit relation major currency unit (can assumed also number decimal places commonly considered currency) currency_name English name currency","code":""},{"path":"/reference/currencies.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ISO-4217 currency data. — currencies","text":"https://en.wikipedia.org/wiki/ISO_4217","code":""},{"path":"/reference/delete_cache.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete vectors cached in a graph object — delete_cache","title":"Delete vectors cached in a graph object — delete_cache","text":"Delete vectors cached graph object class dgr_graph.","code":""},{"path":"/reference/delete_cache.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete vectors cached in a graph object — delete_cache","text":"","code":"delete_cache(graph, name = NULL)"},{"path":"/reference/delete_cache.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete vectors cached in a graph object — delete_cache","text":"graph graph object class dgr_graph. name One name vector objects delete cache. none supplied, cached vectors available graph deleted.","code":""},{"path":"/reference/delete_cache.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete vectors cached in a graph object — delete_cache","text":"vector.","code":""},{"path":"/reference/delete_cache.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete vectors cached in a graph object — delete_cache","text":"","code":"# Create an empty graph graph <- create_graph() # Cache 3 different vectors inside # the graph object graph <- graph %>% set_cache( name = \"a\", to_cache = 1:4) %>% set_cache( name = \"b\", to_cache = 5:9) %>% set_cache( name = \"c\", to_cache = 10:14) # Delete cache `b` graph <- graph %>% delete_cache(name = \"b\") # Delete remaining cached vectors graph <- graph %>% delete_cache()"},{"path":"/reference/delete_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete an edge from an existing graph object — delete_edge","title":"Delete an edge from an existing graph object — delete_edge","text":"graph object class dgr_graph, delete existing edge specifying either: (1) pair node IDs corresponding edge (keeping consideration direction edge directed graph), (2) edge ID.","code":""},{"path":"/reference/delete_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete an edge from an existing graph object — delete_edge","text":"","code":"delete_edge(graph, from = NULL, to = NULL, id = NULL)"},{"path":"/reference/delete_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete an edge from an existing graph object — delete_edge","text":"graph graph object class dgr_graph. node ID edge removed outgoing. edge ID provided id, argument ignored. option use node label value (must correspondingly also done argument) defining node connections. Note possible nodes distinct label values set none exist empty string. node ID edge removed incoming. edge ID provided id, argument ignored. option use node label value (must correspondingly also argument) defining node connections. Note possible nodes distinct label values set none exist empty string. id edge ID edge removed.","code":""},{"path":"/reference/delete_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete an edge from an existing graph object — delete_edge","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete an edge from an existing graph object — delete_edge","text":"","code":"# Create a graph with 2 nodes graph <- create_graph() %>% add_n_nodes(n = 2) # Add an edge graph <- graph %>% add_edge( from = 1, to = 2) # Delete the edge graph <- graph %>% delete_edge( from = 1, to = 2) # Get the count of edges in the graph graph %>% count_edges() #> [1] 0 # Create an undirected graph with # 2 nodes and an edge graph_undirected <- create_graph(directed = FALSE) %>% add_n_nodes(n = 2) %>% add_edge( from = 1, to = 2) # Delete the edge; the order of node ID # values provided in `from` and `to` # don't matter for the undirected case graph_undirected %>% delete_edge( from = 2, to = 1) %>% count_edges() #> [1] 0 # The undirected graph has a single # edge with ID `1`; it can be # deleted by specifying `id` graph_undirected %>% delete_edge(id = 1) %>% count_edges() #> [1] 0 # Create a directed graph with 2 # labeled nodes and an edge graph_labeled_nodes <- create_graph() %>% add_n_nodes( n = 2, label = c(\"one\", \"two\")) %>% add_edge( from = \"one\", to = \"two\") # Delete the edge using the node # labels in `from` and `to`; this # is analogous to creating the # edge using node labels graph_labeled_nodes %>% delete_edge( from = \"one\", to = \"two\") %>% count_edges() #> [1] 0"},{"path":"/reference/delete_edges_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete all selected edges in an edge selection — delete_edges_ws","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"graph object class dgr_graph, delete edges present selection. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/delete_edges_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"","code":"delete_edges_ws(graph)"},{"path":"/reference/delete_edges_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/delete_edges_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_edges_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"","code":"# Create a graph graph <- create_graph() %>% add_n_nodes(n = 3) %>% add_edges_w_string( edges = \"1->3 1->2 2->3\") # Select edges attached to # node with ID `3` (these are # `1`->`3` and `2`->`3`) graph <- graph %>% select_edges_by_node_id(nodes = 3) # Delete edges in selection graph <- graph %>% delete_edges_ws() # Get a count of edges in the graph graph %>% count_edges() #> [1] 1"},{"path":"/reference/delete_global_graph_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"Delete one global attributes stored within graph object class dgr_graph).","code":""},{"path":"/reference/delete_global_graph_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"","code":"delete_global_graph_attrs(graph, attr = NULL, attr_type = NULL)"},{"path":"/reference/delete_global_graph_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"graph graph object class dgr_graph. attr name attribute delete type global attribute specified. attr_type specific type global graph attribute delete. type specified graph, node, edge.","code":""},{"path":"/reference/delete_global_graph_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"graph object class dgr_graph.","code":""},{"path":"/reference/delete_global_graph_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"","code":"# Create a new graph and add # some extra global graph attrs graph <- create_graph() %>% add_global_graph_attrs( attr = \"overlap\", value = \"true\", attr_type = \"graph\") %>% add_global_graph_attrs( attr = \"penwidth\", value = 3, attr_type = \"node\") %>% add_global_graph_attrs( attr = \"penwidth\", value = 3, attr_type = \"edge\") # Inspect the graph's global # attributes graph %>% get_global_graph_attr_info() #> # A tibble: 20 × 3 #> attr value attr_type #> #> 1 layout neato graph #> 2 outputorder edgesfirst graph #> 3 bgcolor white graph #> 4 fontname Helvetica node #> 5 fontsize 10 node #> 6 shape circle node #> 7 fixedsize true node #> 8 width 0.5 node #> 9 style filled node #> 10 fillcolor aliceblue node #> 11 color gray70 node #> 12 fontcolor gray50 node #> 13 fontname Helvetica edge #> 14 fontsize 8 edge #> 15 len 1.5 edge #> 16 color gray80 edge #> 17 arrowsize 0.5 edge #> 18 overlap true graph #> 19 penwidth 3 node #> 20 penwidth 3 edge # Delete the `penwidth` attribute # for the graph's nodes using the # `delete_global_graph_attrs()` fcn graph <- graph %>% delete_global_graph_attrs( attr = \"penwidth\", attr_type = \"node\") # View the remaining set of global # attributes for the graph graph %>% get_global_graph_attr_info() #> # A tibble: 19 × 3 #> attr value attr_type #> #> 1 layout neato graph #> 2 outputorder edgesfirst graph #> 3 bgcolor white graph #> 4 fontname Helvetica node #> 5 fontsize 10 node #> 6 shape circle node #> 7 fixedsize true node #> 8 width 0.5 node #> 9 style filled node #> 10 fillcolor aliceblue node #> 11 color gray70 node #> 12 fontcolor gray50 node #> 13 fontname Helvetica edge #> 14 fontsize 8 edge #> 15 len 1.5 edge #> 16 color gray80 edge #> 17 arrowsize 0.5 edge #> 18 overlap true graph #> 19 penwidth 3 edge"},{"path":"/reference/delete_graph_actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete one or more graph actions stored within a graph object — delete_graph_actions","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"Delete one graph actions stored within graph object class dgr_graph).","code":""},{"path":"/reference/delete_graph_actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"","code":"delete_graph_actions(graph, actions)"},{"path":"/reference/delete_graph_actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"graph graph object class dgr_graph. actions Either vector integer numbers indicating actions delete (based action_index values), , character vector corresponding action_name values.","code":""},{"path":"/reference/delete_graph_actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"graph object class dgr_graph.","code":""},{"path":"/reference/delete_graph_actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 8, set_seed = 23) # Add three graph actions to the # graph graph <- graph %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\", action_name = \"get_pagerank\") %>% add_graph_action( fcn = \"rescale_node_attrs\", node_attr_from = \"pagerank\", node_attr_to = \"width\", action_name = \"pagerank_to_width\") %>% add_graph_action( fcn = \"colorize_node_attrs\", node_attr_from = \"width\", node_attr_to = \"fillcolor\", action_name = \"pagerank_fillcolor\") # View the graph actions for the graph # object by using the `get_graph_actions()` # function graph %>% get_graph_actions() #> # A tibble: 3 × 3 #> action_index action_name expression #> #> 1 1 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_… #> 2 2 pagerank_to_width rescale_node_attrs(graph = graph, node_attr_f… #> 3 3 pagerank_fillcolor colorize_node_attrs(graph = graph, node_attr_… # Delete the second and third graph # actions using `delete_graph_actions()` graph <- graph %>% delete_graph_actions( actions = c(2, 3)) # Verify that these last two graph # actions were deleted by again using # the `get_graph_actions()` function graph %>% get_graph_actions() #> # A tibble: 1 × 3 #> action_index action_name expression #> #> 1 1 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_fcn = …"},{"path":"/reference/delete_loop_edges_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"selection nodes graph, remove associated loop edges. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/delete_loop_edges_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"","code":"delete_loop_edges_ws(graph)"},{"path":"/reference/delete_loop_edges_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/delete_loop_edges_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_loop_edges_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"","code":"# Create an undirected, full graph # of 5 nodes with loops retained graph <- create_graph( directed = FALSE) %>% add_full_graph( n = 5, keep_loops = TRUE) # Select nodes `3` and `4` # and remove the loop edges # associated with those nodes graph <- graph %>% select_nodes_by_id( nodes = 3:4) %>% delete_loop_edges_ws() # Count the number of loop # edges remaining in the graph graph %>% count_loop_edges() #> [1] 3"},{"path":"/reference/delete_node.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete a node from an existing graph object — delete_node","title":"Delete a node from an existing graph object — delete_node","text":"graph object class dgr_graph, delete existing node specifying node ID.","code":""},{"path":"/reference/delete_node.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete a node from an existing graph object — delete_node","text":"","code":"delete_node(graph, node)"},{"path":"/reference/delete_node.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete a node from an existing graph object — delete_node","text":"graph graph object class dgr_graph. node node ID node deleted graph.","code":""},{"path":"/reference/delete_node.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete a node from an existing graph object — delete_node","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_node.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete a node from an existing graph object — delete_node","text":"","code":"# Create a graph with 5 nodes and # edges between each in a path graph <- create_graph() %>% add_path(n = 5) # Delete node with ID `3` graph <- delete_node(graph, node = 3) # Verify that the node with ID `3` # is no longer in the graph graph %>% get_node_ids() #> [1] 1 2 4 5 # Also note that edges are removed # since there were edges between the # removed node to and from other nodes graph %>% get_edges() #> [1] \"1->2\" \"4->5\""},{"path":"/reference/delete_nodes_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete all nodes in a node selection — delete_nodes_ws","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"graph object class dgr_graph, delete nodes present selection nodes. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/delete_nodes_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"","code":"delete_nodes_ws(graph)"},{"path":"/reference/delete_nodes_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/delete_nodes_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_nodes_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"","code":"# Create a graph with 3 nodes graph <- create_graph() %>% add_n_nodes(n = 3) %>% add_edges_w_string( edges = \"1->3 1->2 2->3\") # Select node with ID `1` graph <- graph %>% select_nodes_by_id(nodes = 1) # Delete node in selection (this # also deletes any attached edges) graph <- graph %>% delete_nodes_ws() # Get a count of nodes in the graph graph %>% count_nodes() #> [1] 2"},{"path":"/reference/deselect_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Deselect any selected edges in a graph — deselect_edges","title":"Deselect any selected edges in a graph — deselect_edges","text":"Deselect edges graph object class dgr_graph.","code":""},{"path":"/reference/deselect_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Deselect any selected edges in a graph — deselect_edges","text":"","code":"deselect_edges(graph, edges)"},{"path":"/reference/deselect_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Deselect any selected edges in a graph — deselect_edges","text":"graph graph object class dgr_graph. edges vector edge IDs deselected.","code":""},{"path":"/reference/deselect_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Deselect any selected edges in a graph — deselect_edges","text":"graph object class dgr_graph.","code":""},{"path":"/reference/deselect_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Deselect any selected edges in a graph — deselect_edges","text":"","code":"# Create a graph with # a single path graph <- create_graph() %>% add_path(n = 5) # Select edges with IDs `1` # and `3` graph <- graph %>% select_edges_by_edge_id( edges = c(1, 3)) # Verify that an edge selection # has been made graph %>% get_selection() #> [1] 1 3 # Deselect edge `1` graph <- graph %>% select_edges_by_edge_id( edges = c(1, 3)) %>% deselect_edges(edges = 1) # Verify that the edge selection # has been made for edges `1` and # `3` and that edge `1` has been # deselected (leaving only `3`) graph %>% get_selection() #> [1] 3"},{"path":"/reference/deselect_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Deselect any selected nodes in a graph — deselect_nodes","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"Deselect nodes graph object class dgr_graph.","code":""},{"path":"/reference/deselect_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"","code":"deselect_nodes(graph, nodes)"},{"path":"/reference/deselect_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"graph graph object class dgr_graph. nodes vector node IDs deselected.","code":""},{"path":"/reference/deselect_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"graph object class dgr_graph.","code":""},{"path":"/reference/deselect_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = c(\"a\", \"a\", \"z\", \"z\"), label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = c(\"a\", \"z\", \"a\")) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Explicitly select nodes `1` and `3` graph <- graph %>% select_nodes(nodes = c(1, 3)) %>% deselect_nodes(nodes = 1) # Verify that the node selection # has been made for nodes `1` and # `3` and that node `1` has been # deselected (leaving only `3`) graph %>% get_selection() #> [1] 3"},{"path":"/reference/display_metagraph.html","id":null,"dir":"Reference","previous_headings":"","what":"Display a property graph's underlying model — display_metagraph","title":"Display a property graph's underlying model — display_metagraph","text":"graph object class dgr_graph also property graph (.e., nodes assigned type value edges assigned rel value), display metagraph RStudio Viewer. representation provides combinations edges different rel values nodes distinct type values, including edges nodes type (shown loops). precondition graph property graph can verified using is_property_graph() function.","code":""},{"path":"/reference/display_metagraph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Display a property graph's underlying model — display_metagraph","text":"","code":"display_metagraph(graph)"},{"path":"/reference/display_metagraph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Display a property graph's underlying model — display_metagraph","text":"graph graph object class dgr_graph. graph must fulfill condition property graph, otherwise function yields error.","code":""},{"path":"/reference/display_metagraph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Display a property graph's underlying model — display_metagraph","text":"","code":"# Create a randomized property # graph with 1000 nodes and 1350 edges property_graph <- create_graph() %>% add_gnm_graph( n = 1000, m = 1350, set_seed = 23) %>% select_nodes_by_degree( expressions = \"deg >= 3\") %>% set_node_attrs_ws( node_attr = type, value = \"a\") %>% clear_selection() %>% select_nodes_by_degree( expressions = \"deg < 3\") %>% set_node_attrs_ws( node_attr = type, value = \"b\") %>% clear_selection() %>% select_nodes_by_degree( expressions = \"deg == 0\") %>% set_node_attrs_ws( node_attr = type, value = \"c\") %>% set_node_attr_to_display( attr = type) %>% select_edges_by_node_id( nodes = get_node_ids(.) %>% sample( size = 0.15 * length(.) %>% floor())) %>% set_edge_attrs_ws( edge_attr = rel, value = \"r_1\") %>% invert_selection() %>% set_edge_attrs_ws( edge_attr = rel, value = \"r_2\") %>% clear_selection() %>% copy_edge_attrs( edge_attr_from = rel, edge_attr_to = label) %>% add_global_graph_attrs( attr = \"fontname\", value = \"Helvetica\", attr_type = \"edge\") %>% add_global_graph_attrs( attr = \"fontcolor\", value = \"gray50\", attr_type = \"edge\") %>% add_global_graph_attrs( attr = \"fontsize\", value = 10, attr_type = \"edge\") # Display this graph's # metagraph, or, the underlying # graph model for a property graph # display_metagraph(property_graph)"},{"path":"/reference/do_bfs.html","id":null,"dir":"Reference","previous_headings":"","what":"Use the breadth-first search (bfs) algorithm — do_bfs","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"chosen random node serving starting point, perform breadth-first search whole graph return node ID values visited. bfs algorithm differs depth-first search (dfs) bfs follow tree branches branches one level time terminating leaf node (dfs traverses branches far possible).","code":""},{"path":"/reference/do_bfs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"","code":"do_bfs(graph, node = NULL, direction = \"all\")"},{"path":"/reference/do_bfs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"graph graph object class dgr_graph. node optional node ID value specify single starting point bfs. provided, random node graph chosen. direction Using (default), bfs ignore edge direction traversing graph. , traversals adjacent nodes respect edge direction.","code":""},{"path":"/reference/do_bfs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"vector containing node ID values nodes visited breadth-first search. order node IDs corresponds order visited.","code":""},{"path":"/reference/do_bfs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"","code":"# Create a graph containing # two balanced trees graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) %>% add_balanced_tree( k = 3, h = 2) # Perform a breadth-first # search of the graph, # beginning at the root node # `1` (the default # `direction = \"all\"` doesn't # take edge direction into # account) graph %>% do_bfs(node = 1) #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # If not specifying a # starting node, the function # will begin the search from # a random node graph %>% do_bfs() #> [1] 9 8 12 13 14 10 11 15 16 17 18 19 20 1 2 3 4 5 6 7 # It's also possible to # perform bfs while taking # into account edge direction; # using `direction = \"in\"` # causes the bfs routine to # visit nodes along inward edges graph %>% do_bfs( node = 1, direction = \"in\") #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # Using `direction = \"out\"` # results in the bfs moving # along solely outward edges graph %>% do_bfs( node = 1, direction = \"out\") #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"},{"path":"/reference/do_dfs.html","id":null,"dir":"Reference","previous_headings":"","what":"Use the depth-first search (dfs) algorithm — do_dfs","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"chosen random node serving starting point, perform depth-first search whole graph return node ID values visited. dfs algorithm differs breadth-first search (bfs) dfs follow tree branches far possible terminating leaf node (bfs traverses branches one level time).","code":""},{"path":"/reference/do_dfs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"","code":"do_dfs(graph, node = NULL, direction = \"all\")"},{"path":"/reference/do_dfs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"graph graph object class dgr_graph. node optional node ID value specify single starting point dfs. provided, random node graph chosen. direction Using (default), bfs ignore edge direction traversing graph. , traversals adjacent nodes respect edge direction.","code":""},{"path":"/reference/do_dfs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"vector containing node ID values nodes visited depth-first search. order node IDs corresponds order visited.","code":""},{"path":"/reference/do_dfs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"","code":"# Create a graph containing # two balanced trees graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) %>% add_balanced_tree( k = 3, h = 2) # Perform a depth-first # search of the graph, # beginning at the root # node `1` (the default # `direction = \"all\"` # doesn't take edge # direction into account) graph %>% do_dfs(node = 1) #> [1] 1 2 4 5 3 6 7 8 9 12 13 14 10 15 16 17 11 18 19 20 # If not specifying a # starting node, the function # will begin the search # from a random node graph %>% do_dfs() #> [1] 2 1 3 6 7 4 5 8 9 12 13 14 10 15 16 17 11 18 19 20 # It's also possible to # perform dfs while taking # into account edge direction; # using `direction = \"in\"` # causes the dfs routine to # visit nodes along inward edges graph %>% do_dfs( node = 1, direction = \"in\") #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # Using `direction = \"out\"` # results in the dfs moving # along solely outward edges graph %>% do_dfs( node = 1, direction = \"out\") #> [1] 1 2 4 5 3 6 7 8 9 12 13 14 10 15 16 17 11 18 19 20"},{"path":"/reference/drop_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Drop an edge attribute column — drop_edge_attrs","title":"Drop an edge attribute column — drop_edge_attrs","text":"Within graph's internal edge data frame (edf), remove existing edge attribute.","code":""},{"path":"/reference/drop_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drop an edge attribute column — drop_edge_attrs","text":"","code":"drop_edge_attrs(graph, edge_attr)"},{"path":"/reference/drop_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Drop an edge attribute column — drop_edge_attrs","text":"graph graph object class dgr_graph. edge_attr name edge attribute column drop.","code":""},{"path":"/reference/drop_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Drop an edge attribute column — drop_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/drop_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Drop an edge attribute column — drop_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 6, set_seed = 23) %>% set_edge_attrs( edge_attr = value, values = 3) %>% mutate_edge_attrs( penwidth = value * 2) # Get the graph's internal # edf to show which edge # attributes are available graph %>% get_edge_df() #> id from to rel value penwidth #> 1 1 1 4 3 6 #> 2 2 2 3 3 6 #> 3 3 2 4 3 6 #> 4 4 3 1 3 6 #> 5 5 4 1 3 6 #> 6 6 5 4 3 6 # Drop the `value` edge # attribute graph <- graph %>% drop_edge_attrs( edge_attr = value) # Get the graph's internal # edf to show that the edge # attribute `value` had been # removed graph %>% get_edge_df() #> id from to rel penwidth #> 1 1 1 4 6 #> 2 2 2 3 6 #> 3 3 2 4 6 #> 4 4 3 1 6 #> 5 5 4 1 6 #> 6 6 5 4 6"},{"path":"/reference/drop_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Drop a node attribute column — drop_node_attrs","title":"Drop a node attribute column — drop_node_attrs","text":"Within graph's internal node data frame (ndf), remove existing node attribute.","code":""},{"path":"/reference/drop_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drop a node attribute column — drop_node_attrs","text":"","code":"drop_node_attrs(graph, node_attr)"},{"path":"/reference/drop_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Drop a node attribute column — drop_node_attrs","text":"graph graph object class dgr_graph. node_attr name node attribute column drop.","code":""},{"path":"/reference/drop_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Drop a node attribute column — drop_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/drop_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Drop a node attribute column — drop_node_attrs","text":"","code":"graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the graph's internal # ndf to show which node # attributes are available graph %>% get_node_df() #> id type label value #> 1 1 1 5.3 #> 2 2 2 4.4 #> 3 3 3 5.8 #> 4 4 4 5.9 #> 5 5 5 6.2 # Drop the `value` node # attribute graph <- graph %>% drop_node_attrs( node_attr = value) # Get the graph's internal # ndf to show that the node # attribute `value` had been # removed graph %>% get_node_df() #> id type label #> 1 1 1 #> 2 2 2 #> 3 3 3 #> 4 4 4 #> 5 5 5"},{"path":"/reference/edge_aes.html","id":null,"dir":"Reference","previous_headings":"","what":"Insert edge aesthetic attributes during edge creation — edge_aes","title":"Insert edge aesthetic attributes during edge creation — edge_aes","text":"helper function invoked provide values namesake edge_aes argument, present function edges created.","code":""},{"path":"/reference/edge_aes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insert edge aesthetic attributes during edge creation — edge_aes","text":"","code":"edge_aes( style = NULL, penwidth = NULL, color = NULL, arrowsize = NULL, arrowhead = NULL, arrowtail = NULL, fontname = NULL, fontsize = NULL, fontcolor = NULL, len = NULL, tooltip = NULL, URL = NULL, label = NULL, labelfontname = NULL, labelfontsize = NULL, labelfontcolor = NULL, labeltooltip = NULL, labelURL = NULL, edgetooltip = NULL, edgeURL = NULL, dir = NULL, headtooltip = NULL, headURL = NULL, headclip = NULL, headlabel = NULL, headport = NULL, tailtooltip = NULL, tailURL = NULL, tailclip = NULL, taillabel = NULL, tailport = NULL, decorate = NULL )"},{"path":"/reference/edge_aes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insert edge aesthetic attributes during edge creation — edge_aes","text":"style edge line style. style types can used solid, bold, dashed, dotted, tapered, invisible. penwidth thickness stroke line edge . color color edge. Can X11 color hexadecimal color code. arrowsize scaling factor arrowheads. default value 1.0 minimum 0. arrowhead type arrowhead use. style attribute can types: normal, vee, tee, dot, diamond, box, curve, icurve, inv, crow, none. arrowtail type arrowtail use. style attribute can types: normal, vee, tee, dot, diamond, box, curve, icurve, inv, crow, none. fontname name system font used edge text. fontsize point size font used edge text. fontcolor color used edge text. Can X11 color hexadecimal color code. len preferred edge length edge, inches. Default value 1.0. tooltip Text tooltip appears hovering edge. text provided, default tooltip text provide edge definition (.e., [id]->[id] [id]--[id]). URL URL associate edge. Upon rendering plot, clicking edges associated URLs open URL default browser. label label text associated edge. text appear near center edge. labelfontname name system font used headlabel taillabel label text. set, fontname value instead used. labelfontsize point size font used headlabel taillabel label text. set, fontsize value instead used. labelfontcolor color used label text headlabel taillabel label text. set, fontcolor value instead used. Can X11 color hexadecimal color code. labeltooltip Text tooltip appear hovering main label edge (label text provided label edge attribute). text provided edge label visible, default tooltip text provide edge definition (.e., [id]->[id] [id]--[id]). labelURL URL associate edge label text. Upon rendering plot, clicking edge labels associated URLs open URL default browser. edgetooltip option provides means specify tooltip non-label parts edge. defined, value overrides tooltip defined edge. tooltip text hovering along edge (even near head tail node) unless overridden headtooltip tailtooltip value. edgeURL option provides means specify URL non-label parts edge. defined, value overrides URL defined edge. URL used along edge (even near head tail node) unless overridden headURL tailURL value. dir optional direction type. Normally, directed graphs, forward needn't set. undirected graphs, none explicit setting required. However, one can also use back options. back option draws arrowhead reverse direction edge. option draws two arrowheads. using options explicit manner, head... tail... edge attributes allow control aesthetic edge attributes either side edge. headtooltip option provides means specify tooltip can displayed hovering part edge adjacent incoming node (see tooltip argument details). headURL option provides means specify URL can accessed clicking part edge adjacent incoming node (see URL argument details). headclip TRUE (default behavior), head affected edge clipped node boundary. Using FALSE places head outgoing edge center node. headlabel option provides means display label near part edge adjacent incoming node (see label argument details). headport Allows one specify compass position incoming node head edge alight. Options n, ne, e, se, s, sw, w, nw. tailtooltip option provides means specify tooltip can displayed hovering part edge adjacent outgoing node (see tooltip argument details). tailURL option provides means specify URL can accessed clicking part edge adjacent outgoing node (see URL argument details). tailclip TRUE (default behavior), tail affected edge clipped node boundary. Using FALSE places tail outgoing edge center node. taillabel option provides means display label near part edge adjacent outgoing node (see label argument details). tailport Allows one specify compass position outgoing node tail edge emitted . Options n, ne, e, se, s, sw, w, nw. decorate TRUE attach edge label edge line via 2-segment polyline, underlining label text partially overlapping edge line.","code":""},{"path":[]},{"path":"/reference/edge_aes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insert edge aesthetic attributes during edge creation — edge_aes","text":"","code":"# Create a new graph and add # a path with several edge # aesthetic attributes graph <- create_graph() %>% add_path( n = 3, type = \"path\", edge_aes = edge_aes( style = \"dot\", color = c(\"red\", \"blue\"))) # View the graph's internal # node data frame; the node # aesthetic attributes have # been inserted graph %>% get_edge_df() #> id from to rel style color #> 1 1 1 2 dot red #> 2 2 2 3 dot blue"},{"path":"/reference/edge_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Insert edge data attributes during edge creation — edge_data","title":"Insert edge data attributes during edge creation — edge_data","text":"helper function invoked provide values namesake edge_data argument, present function edges created.","code":""},{"path":"/reference/edge_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insert edge data attributes during edge creation — edge_data","text":"","code":"edge_data(...)"},{"path":"/reference/edge_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insert edge data attributes during edge creation — edge_data","text":"... Edge data attributes provided one named vectors.","code":""},{"path":[]},{"path":"/reference/edge_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insert edge data attributes during edge creation — edge_data","text":"","code":"if (FALSE) { # Create a new graph and add # a path with several edge # data attributes graph <- create_graph() %>% add_path( n = 3, type = \"path\", edge_data = edge_data( hour = 5, index = c(1, 2))) # View the graph's internal # edge data frame; the edge # data attributes have # been inserted graph %>% get_edge_df() }"},{"path":"/reference/edge_list_1.html","id":null,"dir":"Reference","previous_headings":"","what":"Edge list - Version 1. — edge_list_1","title":"Edge list - Version 1. — edge_list_1","text":"simple, 2-column data frame can used generate graph edges.","code":""},{"path":"/reference/edge_list_1.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Edge list - Version 1. — edge_list_1","text":"","code":"edge_list_1"},{"path":"/reference/edge_list_1.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Edge list - Version 1. — edge_list_1","text":"data frame 19 rows 2 variables: integer values state node ID values edge starts integer values state node ID values edge terminates","code":""},{"path":"/reference/edge_list_2.html","id":null,"dir":"Reference","previous_headings":"","what":"Edge list - Version 2. — edge_list_2","title":"Edge list - Version 2. — edge_list_2","text":"simple, 5-column data frame can used generate graph edges.","code":""},{"path":"/reference/edge_list_2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Edge list - Version 2. — edge_list_2","text":"","code":"edge_list_2"},{"path":"/reference/edge_list_2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Edge list - Version 2. — edge_list_2","text":"data frame 19 rows 5 variables: integer values state node ID values edge starts integer values state node ID values edge terminates rel grouping variable either , b, c value_1 randomized set numeric values 0 10 value_2 randomized set numeric values 0 10","code":""},{"path":"/reference/export_csv.html","id":null,"dir":"Reference","previous_headings":"","what":"Export a graph to CSV files — export_csv","title":"Export a graph to CSV files — export_csv","text":"Export graph separate CSV files nodes edges.","code":""},{"path":"/reference/export_csv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export a graph to CSV files — export_csv","text":"","code":"export_csv( graph, ndf_name = \"nodes.csv\", edf_name = \"edges.csv\", output_path = getwd(), colnames_type = NULL )"},{"path":"/reference/export_csv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export a graph to CSV files — export_csv","text":"graph graph object class dgr_graph. ndf_name name provide CSV file containing node information. default CSV called nodes.csv. edf_name name provide CSV file containing edge information. default CSV called edges.csv. output_path path CSV files placed. default, current working directory. colnames_type Provides options modify CSV column names allow easier import graph systems. neo4j option modifies column names allow direct import CSVs Neo4J LOAD CSV clause. graphframes option modifies column names match required Spark GraphFrames package.","code":""},{"path":"/reference/export_csv.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export a graph to CSV files — export_csv","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = c(\"a\", \"a\", \"z\", \"z\"), label = TRUE, value = c(3.5, 2.6, 9.4, 2.7) ) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = c(\"rel_a\", \"rel_z\", \"rel_a\") ) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf ) # Create separate `nodes.csv` and # `edges.csv` files # graph %>% export_csv()"},{"path":"/reference/export_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Export a graph to various image formats — export_graph","title":"Export a graph to various image formats — export_graph","text":"Export graph variety image formats PNG, PDF, SVG, PostScript.","code":""},{"path":"/reference/export_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export a graph to various image formats — export_graph","text":"","code":"export_graph( graph, file_name = NULL, file_type = NULL, title = NULL, width = NULL, height = NULL )"},{"path":"/reference/export_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export a graph to various image formats — export_graph","text":"graph graph object class dgr_graph. file_name name exported file (including extension). file_type type file exported. Options graph files : png, pdf, svg, ps. title optional title output graph. width Output width pixels NULL default. useful export image file formats png, pdf, svg, ps. height Output height pixels NULL default. useful export image file formats png, pdf, svg, ps.","code":""},{"path":[]},{"path":"/reference/export_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export a graph to various image formats — export_graph","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_path( n = 5, edge_aes = edge_aes( arrowhead = c( \"normal\", \"vee\", \"tee\", \"dot\" ), color = c( \"red\", \"blue\", \"orange\", \"purple\" ) ) ) # Create a PDF file for # the graph (`graph.pdf`) # graph %>% # export_graph( # file_name = \"graph.pdf\", # title = \"Simple Graph\" # ) # Create a PNG file for # the graph (`mypng.png`) # graph %>% # export_graph( # file_name = \"mypng.png\", # file_type = \"PNG\" # )"},{"path":"/reference/filter_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Subset a graph series object — filter_graph_series","title":"Subset a graph series object — filter_graph_series","text":"Subsetting graph series graphs' index positions graph series selection via graphs' date-time attributes.","code":""},{"path":"/reference/filter_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subset a graph series object — filter_graph_series","text":"","code":"filter_graph_series(graph_series, by = \"number\", values, tz = NULL)"},{"path":"/reference/filter_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subset a graph series object — filter_graph_series","text":"graph_series graph series object type dgr_graph_1D. Either number, allows subsetting graph series graph indices, time graph series objects type temporal allows subsetting graphs date-time time range. values subsetting graph series occur via graph indices (= number), provide vector indices; subsetting time (= time), range times can provided vector. tz time zone (tz) corresponding dates date-time string provided values (= \"date\").","code":""},{"path":"/reference/filter_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subset a graph series object — filter_graph_series","text":"graph series object type dgr_graph_1D.","code":""},{"path":"/reference/filter_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subset a graph series object — filter_graph_series","text":"","code":"# Create three graphs graph_time_1 <- create_graph( graph_name = \"graph_with_time_1\") %>% set_graph_time( time = \"2015-03-25 03:00\", tz = \"GMT\") graph_time_2 <- create_graph( graph_name = \"graph_with_time_2\") %>% set_graph_time( time = \"2015-03-26 03:00\", tz = \"GMT\") graph_time_3 <- create_graph( graph_name = \"graph_with_time_3\") %>% set_graph_time( time = \"2015-03-27 15:00\", tz = \"GMT\") # Create an empty graph series and add # the graphs series_temporal <- create_graph_series( series_type = \"temporal\") %>% add_graph_to_graph_series( graph = graph_time_1) %>% add_graph_to_graph_series( graph = graph_time_2) %>% add_graph_to_graph_series( graph = graph_time_3) # Subset graph series by sequence series_sequence_subset <- filter_graph_series( graph_series = series_temporal, by = \"number\", values = 2) # Get a count of graphs in # the series series_sequence_subset %>% count_graphs_in_graph_series() #> [1] 1 # Subset graph series by date-time series_time_subset <- filter_graph_series( graph_series = series_temporal, by = \"time\", values = c(\"2015-03-25 12:00\", \"2015-03-26 12:00\"), tz = \"GMT\") # Get a count of graphs in # the series series_time_subset %>% count_graphs_in_graph_series() #> [1] 2"},{"path":"/reference/from_adj_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a graph using an adjacency matrix — from_adj_matrix","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"Using adjacency matrix object, generate graph class dgr_graph.","code":""},{"path":"/reference/from_adj_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"","code":"from_adj_matrix( x, mode = \"undirected\", weighted = FALSE, use_diag = TRUE, graph_name = NULL, write_backups = FALSE, display_msgs = FALSE )"},{"path":"/reference/from_adj_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"x square matrix object serving adjacency matrix. mode method interpret input adjacency matrix. Options include: undirected, directed, upper, lower, max, min, plus. weighted Whether create weighted graph adjacency matrix. use_diag Whether use diagonal adjacency matrix calculations. TRUE diagonal values included . FALSE diagonal values replaced zero values inclusion calculations. graph_name optional string labeling graph object. write_backups option write incremental backups changing graph states disk. TRUE, subdirectory within working directory created used store RDS files. default value FALSE one opt use functionality. display_msgs option display messages primarily concerned changes graph selections. default, FALSE.","code":""},{"path":"/reference/from_adj_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"graph object class dgr_graph.","code":""},{"path":"/reference/from_adj_matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"","code":"# Create an adjacency matrix adj_matrix <- sample( 0:1, 100, replace = TRUE, prob = c(0.9,0.1) ) %>% matrix(ncol = 10) # Create a graph from the adjacency matrix graph <- from_adj_matrix(adj_matrix)"},{"path":"/reference/from_igraph.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an igraph graph to a DiagrammeR one — from_igraph","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"Convert igraph graph DiagrammeR graph object.","code":""},{"path":"/reference/from_igraph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"","code":"from_igraph( igraph, graph_name = NULL, write_backups = FALSE, display_msgs = FALSE )"},{"path":"/reference/from_igraph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"igraph igraph graph object. graph_name optional string labeling graph object. write_backups option write incremental backups changing graph states disk. TRUE, subdirectory within working directory created used store RDS files. default value FALSE one opt use functionality. display_msgs option display messages primarily concerned changes graph selections. default, FALSE.","code":""},{"path":"/reference/from_igraph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/from_igraph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"","code":"# Create a DiagrammeR graph object dgr_graph_orig <- create_graph() %>% add_gnm_graph( n = 36, m = 50, set_seed = 23) # Convert the DiagrammeR # graph to an igraph object ig_graph <- dgr_graph_orig %>% to_igraph() # Convert the igraph graph # back to a DiagrammeR graph dgr_graph_new <- ig_graph %>% from_igraph() # Get some graph information (dgr_graph_new %>% get_graph_info())[, 1:6] #> name n e dens mn_deg mx_deg #> 1 graph_hWHYG7a9 36 50 0.0571 1 7"},{"path":"/reference/fully_connect_nodes_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"selection nodes graph, add remaining edges required fully connect group edges . function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/fully_connect_nodes_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"","code":"fully_connect_nodes_ws(graph)"},{"path":"/reference/fully_connect_nodes_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/fully_connect_nodes_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"graph object class dgr_graph.","code":""},{"path":"/reference/fully_connect_nodes_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"","code":"# Create an empty graph and # then add a path of 3 nodes # and two isolated nodes graph <- create_graph() %>% add_path(n = 3) %>% add_n_nodes(n = 2) # Select a node in the path # of nodes (node `3`) and # the two isolated nodes (`4` # and `5`); then, and fully # connect these nodes together graph <- graph %>% select_nodes_by_id( nodes = 3:5) %>% fully_connect_nodes_ws() # Get the graph's edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 3 5 #> 5 5 4 5 #> 6 6 4 3 #> 7 7 5 3 #> 8 8 5 4 # Create an undirected, empty # graph; add a path of 3 nodes # and two isolated nodes graph <- create_graph( directed = FALSE) %>% add_path(n = 3) %>% add_n_nodes(n = 2) # Select a node in the path # of nodes (node `3`) and # the two isolated nodes (`4` # and `5`); then, and fully # connect these nodes together graph <- graph %>% select_nodes_by_id( nodes = 3:5) %>% fully_connect_nodes_ws() # Get the graph's edge data # frame; in the undirected # case, reverse edges aren't # added graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 3 5 #> 5 5 4 5 "},{"path":"/reference/fully_disconnect_nodes_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"selection nodes graph, remove edges nodes.","code":""},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"","code":"fully_disconnect_nodes_ws(graph)"},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"graph object class dgr_graph.","code":""},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"","code":"# Create an empty graph and # add a path of 6 nodes graph <- create_graph() %>% add_path(n = 6) # Select nodes `3` and `4` # and fully disconnect them # from the graph graph <- graph %>% select_nodes_by_id( nodes = 3:4) %>% fully_disconnect_nodes_ws() # Get the graph's edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 5 5 6 "},{"path":"/reference/generate_dot.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate DOT code using a graph object — generate_dot","title":"Generate DOT code using a graph object — generate_dot","text":"Generates Graphviz DOT code R character object using DiagrammeR graph object.","code":""},{"path":"/reference/generate_dot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate DOT code using a graph object — generate_dot","text":"","code":"generate_dot(graph)"},{"path":"/reference/generate_dot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate DOT code using a graph object — generate_dot","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/generate_dot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate DOT code using a graph object — generate_dot","text":"character vector length 1 containing Graphviz DOT code.","code":""},{"path":"/reference/get_adhesion.html","id":null,"dir":"Reference","previous_headings":"","what":"Get graph adhesion — get_adhesion","title":"Get graph adhesion — get_adhesion","text":"Get adhesion graph, minimum number edges needed remove obtain graph strongly connected. edge connectivity graph.","code":""},{"path":"/reference/get_adhesion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get graph adhesion — get_adhesion","text":"","code":"get_adhesion(graph)"},{"path":"/reference/get_adhesion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get graph adhesion — get_adhesion","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_adhesion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get graph adhesion — get_adhesion","text":"single numeric value representing minimum number edges remove.","code":""},{"path":"/reference/get_adhesion.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get graph adhesion — get_adhesion","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the graph's adhesion graph %>% get_adhesion() #> [1] 1 # Create a full graph and then # get the adhesion for that create_graph() %>% add_full_graph(n = 8) %>% get_adhesion() #> [1] 7"},{"path":"/reference/get_agg_degree_in.html","id":null,"dir":"Reference","previous_headings":"","what":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"Get single, aggregate value indegree values nodes graph, , subset graph nodes.","code":""},{"path":"/reference/get_agg_degree_in.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"","code":"get_agg_degree_in(graph, agg, conditions = NULL)"},{"path":"/reference/get_agg_degree_in.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"graph graph object class dgr_graph. agg aggregation function use summarizing indegree values graph nodes. following aggregation functions can used: sum, min, max, mean, median. conditions option use filtering conditions nodes consider.","code":""},{"path":"/reference/get_agg_degree_in.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"vector aggregate indegree value.","code":""},{"path":"/reference/get_agg_degree_in.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 20, m = 35, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the mean indegree value # from all nodes in the graph graph %>% get_agg_degree_in( agg = \"mean\") #> [1] 1.75 # Other aggregation functions # can be used (`min`, `max`, # `median`, `sum`); let's get # the median in this example graph %>% get_agg_degree_in( agg = \"median\") #> [1] 1.5 # The aggregation of indegree # can occur for a subset of the # graph nodes and this is made # possible by specifying # `conditions` for the nodes graph %>% get_agg_degree_in( agg = \"mean\", conditions = value > 5.0) #> [1] 1.5"},{"path":"/reference/get_agg_degree_out.html","id":null,"dir":"Reference","previous_headings":"","what":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"Get single, aggregate value outdegree values nodes graph, , subset graph nodes.","code":""},{"path":"/reference/get_agg_degree_out.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"","code":"get_agg_degree_out(graph, agg, conditions = NULL)"},{"path":"/reference/get_agg_degree_out.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"graph graph object class dgr_graph. agg aggregation function use summarizing outdegree values graph nodes. following aggregation functions can used: sum, min, max, mean, median. conditions option use filtering conditions nodes consider.","code":""},{"path":"/reference/get_agg_degree_out.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"vector aggregate outdegree value.","code":""},{"path":"/reference/get_agg_degree_out.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 20, m = 35, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the mean outdegree value from all # nodes in the graph graph %>% get_agg_degree_out( agg = \"mean\") #> [1] 1.75 # Other aggregation functions can be used # (`min`, `max`, `median`, `sum`); let's # get the median in this example graph %>% get_agg_degree_out( agg = \"median\") #> [1] 1 # The aggregation of outdegree can occur # for a subset of the graph nodes and this # is made possible by specifying `conditions` # for the nodes graph %>% get_agg_degree_out( agg = \"mean\", conditions = value < 5.0) #> [1] 2.555556"},{"path":"/reference/get_agg_degree_total.html","id":null,"dir":"Reference","previous_headings":"","what":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"Get single, aggregate value total degree values nodes graph, , subset graph nodes.","code":""},{"path":"/reference/get_agg_degree_total.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"","code":"get_agg_degree_total(graph, agg, conditions = NULL)"},{"path":"/reference/get_agg_degree_total.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"graph graph object class dgr_graph. agg aggregation function use summarizing total degree values graph nodes. following aggregation functions can used: sum, min, max, mean, median. conditions option use filtering conditions nodes consider.","code":""},{"path":"/reference/get_agg_degree_total.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"vector aggregate total degree value.","code":""},{"path":"/reference/get_agg_degree_total.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 20, m = 35, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the mean total degree # value from all nodes in # the graph graph %>% get_agg_degree_total( agg = \"mean\") #> [1] 3.5 # Other aggregation functions # can be used (`min`, `max`, # `median`, `sum`); let's get # the median in this example graph %>% get_agg_degree_total( agg = \"median\") #> [1] 3 # The aggregation of total # degree can occur for a # subset of the graph nodes # and this is made possible # by specifying `conditions` # for the nodes graph %>% get_agg_degree_total( agg = \"mean\", conditions = value < 5.0) #> [1] 4.666667"},{"path":"/reference/get_all_connected_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Get all nodes connected to a specified node — get_all_connected_nodes","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"single node serving starting point get nodes connected (.e., reachable traversable path) node.","code":""},{"path":"/reference/get_all_connected_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"","code":"get_all_connected_nodes(graph, node)"},{"path":"/reference/get_all_connected_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"graph graph object class dgr_graph. node single-length vector containing node ID value.","code":""},{"path":"/reference/get_all_connected_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"vector node ID values.","code":""},{"path":"/reference/get_all_connected_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function; it # has an unconnected node (`6`) graph_1 <- create_graph() %>% add_gnm_graph( n = 20, m = 32, set_seed = 23) # There won't be any connected # nodes to `6` so when specifying # this node with `get_all_connected_nodes()` # we get NA back graph_1 %>% get_all_connected_nodes( node = 6) #> [1] NA # Any other node in `graph_1` will # provide a vector of all the nodes # other than `6` graph_1 %>% get_all_connected_nodes( node = 1) #> [1] 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # The following graph has two # clusters of nodes (i.e., the # graph has two connected components) graph_2 <- create_graph() %>% add_path(n = 6) %>% add_path(n = 4) # In `graph_2`, node `1` is in # the larger of the two # connected components graph_2 %>% get_all_connected_nodes( node = 1) #> [1] 2 3 4 5 6 # Also in `graph_2`, node `8` # is in the smaller of the two # connected components graph_2 %>% get_all_connected_nodes( node = 8) #> [1] 7 9 10"},{"path":"/reference/get_alpha_centrality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the alpha centrality for all nodes — get_alpha_centrality","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"Get alpha centrality values nodes graph.","code":""},{"path":"/reference/get_alpha_centrality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"","code":"get_alpha_centrality( graph, alpha = 1, exo = 1, weights_attr = NULL, tol = 1e-07 )"},{"path":"/reference/get_alpha_centrality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"graph graph object class dgr_graph. alpha parameter specifies relative importance endogenous versus exogenous factors determination centrality. exo exogenous factors, cases either constant (applies factor every node), vector giving factor every node. weights_attr optional name edge attribute use adjacency matrix. NULL , exists, weight edge attribute graph used. Failing , standard adjacency matrix used calculations. tol tolerance near-singularities matrix inversion. default value set 1e-7.","code":""},{"path":"/reference/get_alpha_centrality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"data frame alpha centrality scores nodes.","code":""},{"path":"/reference/get_alpha_centrality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) # Get the alpha centrality scores # for all nodes graph %>% get_alpha_centrality() #> id alpha_centrality #> 1 1 9 #> 2 2 6 #> 3 3 2 #> 4 4 1 #> 5 5 4 #> 6 6 1 #> 7 7 2 #> 8 8 2 #> 9 9 7 #> 10 10 4 # Add the alpha centrality # scores to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_alpha_centrality(.)) # Display the graph's node # data frame graph %>% get_node_df() #> id type label alpha_centrality #> 1 1 1 9 #> 2 2 2 6 #> 3 3 3 2 #> 4 4 4 1 #> 5 5 5 4 #> 6 6 6 1 #> 7 7 7 2 #> 8 8 8 2 #> 9 9 9 7 #> 10 10 10 4"},{"path":"/reference/get_articulation_points.html","id":null,"dir":"Reference","previous_headings":"","what":"Get articulation points — get_articulation_points","title":"Get articulation points — get_articulation_points","text":"Get nodes graph identified articulation points.","code":""},{"path":"/reference/get_articulation_points.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get articulation points — get_articulation_points","text":"","code":"get_articulation_points(graph)"},{"path":"/reference/get_articulation_points.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get articulation points — get_articulation_points","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_articulation_points.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get articulation points — get_articulation_points","text":"vector node IDs.","code":""},{"path":"/reference/get_articulation_points.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get articulation points — get_articulation_points","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) %>% set_node_attrs( node_attr = shape, values = \"square\") # Get the articulation points # in the graph (i.e., those # nodes that if any were to be # removed, the graph would # become disconnected) graph %>% get_articulation_points() #> [1] 2 4 # For the articulation points, # change the node shape to # a `circle` graph <- graph %>% select_nodes_by_id( nodes = get_articulation_points(.)) %>% set_node_attrs_ws( node_attr = shape, value = \"circle\")"},{"path":"/reference/get_authority_centrality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the authority scores for all nodes — get_authority_centrality","title":"Get the authority scores for all nodes — get_authority_centrality","text":"Get Kleinberg authority centrality scores nodes graph.","code":""},{"path":"/reference/get_authority_centrality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the authority scores for all nodes — get_authority_centrality","text":"","code":"get_authority_centrality(graph, weights_attr = NULL)"},{"path":"/reference/get_authority_centrality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the authority scores for all nodes — get_authority_centrality","text":"graph graph object class dgr_graph. weights_attr optional name edge attribute use adjacency matrix. NULL , exists, weight edge attribute graph used.","code":""},{"path":"/reference/get_authority_centrality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the authority scores for all nodes — get_authority_centrality","text":"data frame authority scores nodes.","code":""},{"path":"/reference/get_authority_centrality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the authority scores for all nodes — get_authority_centrality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the authority centrality scores # for all nodes in the graph graph %>% get_authority_centrality() #> id authority_centrality #> 1 1 6.950912e-01 #> 2 2 6.176471e-01 #> 3 3 0.000000e+00 #> 4 4 1.078669e-16 #> 5 5 3.674279e-01 #> 6 6 3.157923e-01 #> 7 7 4.982552e-01 #> 8 8 1.000000e+00 #> 9 9 1.824629e-01 #> 10 10 6.176471e-01 # Add the authority centrality # scores to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_authority_centrality(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label authority_centrality #> 1 1 1 6.950912e-01 #> 2 2 2 6.176471e-01 #> 3 3 3 0.000000e+00 #> 4 4 4 1.078669e-16 #> 5 5 5 3.674279e-01 #> 6 6 6 3.157923e-01 #> 7 7 7 4.982552e-01 #> 8 8 8 1.000000e+00 #> 9 9 9 1.824629e-01 #> 10 10 10 6.176471e-01"},{"path":"/reference/get_betweenness.html","id":null,"dir":"Reference","previous_headings":"","what":"Get betweenness centrality scores — get_betweenness","title":"Get betweenness centrality scores — get_betweenness","text":"Get betweenness centrality scores nodes graph.","code":""},{"path":"/reference/get_betweenness.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get betweenness centrality scores — get_betweenness","text":"","code":"get_betweenness(graph)"},{"path":"/reference/get_betweenness.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get betweenness centrality scores — get_betweenness","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_betweenness.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get betweenness centrality scores — get_betweenness","text":"data frame betweenness scores nodes.","code":""},{"path":"/reference/get_betweenness.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get betweenness centrality scores — get_betweenness","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) # Get the betweenness scores # for nodes in the graph graph %>% get_betweenness() #> id betweenness #> 1 1 0 #> 2 2 7 #> 3 3 0 #> 4 4 0 #> 5 5 5 #> 6 6 0 #> 7 7 0 #> 8 8 1 #> 9 9 0 #> 10 10 0 # Add the betweenness # values to the graph # as a node attribute graph <- graph %>% join_node_attrs( df = get_betweenness(.)) # Display the graph's node # data frame graph %>% get_node_df() #> id type label betweenness #> 1 1 1 0 #> 2 2 2 7 #> 3 3 3 0 #> 4 4 4 0 #> 5 5 5 5 #> 6 6 6 0 #> 7 7 7 0 #> 8 8 8 1 #> 9 9 9 0 #> 10 10 10 0"},{"path":"/reference/get_cache.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a cached vector from a graph object — get_cache","title":"Get a cached vector from a graph object — get_cache","text":"Get vector cached graph object class dgr_graph.","code":""},{"path":"/reference/get_cache.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a cached vector from a graph object — get_cache","text":"","code":"get_cache(graph, name = NULL)"},{"path":"/reference/get_cache.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a cached vector from a graph object — get_cache","text":"graph graph object class dgr_graph. name name object extract cache. none supplied, recent object added cache returned.","code":""},{"path":"/reference/get_cache.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a cached vector from a graph object — get_cache","text":"vector.","code":""},{"path":"/reference/get_cache.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a cached vector from a graph object — get_cache","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a graph with 5 nodes and 5 edges graph <- create_graph() %>% add_n_nodes(n = 5) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 8, sd = 2)) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->2\") # Cache all values from the node attribute `value` # as a numeric vector graph <- graph %>% set_cache( name = \"value\", to_cache = get_node_attrs( graph = ., node_attr = value)) # Return the cached vector graph %>% get_cache() #> 1 2 3 4 5 #> 9.993210 10.214981 7.443827 10.038411 8.090874"},{"path":"/reference/get_closeness.html","id":null,"dir":"Reference","previous_headings":"","what":"Get closeness centrality values — get_closeness","title":"Get closeness centrality values — get_closeness","text":"Get closeness centrality values nodes graph.","code":""},{"path":"/reference/get_closeness.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get closeness centrality values — get_closeness","text":"","code":"get_closeness(graph, direction = \"all\")"},{"path":"/reference/get_closeness.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get closeness centrality values — get_closeness","text":"graph graph object class dgr_graph. direction using (default), search ignore edge direction traversing graph. , measurements paths node whereas , measurements paths node.","code":""},{"path":"/reference/get_closeness.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get closeness centrality values — get_closeness","text":"data frame closeness values nodes.","code":""},{"path":"/reference/get_closeness.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get closeness centrality values — get_closeness","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) # Get closeness values for all nodes # in the graph graph %>% get_closeness() #> id closeness #> 1 1 0.05263158 #> 2 2 0.06250000 #> 3 3 0.05555556 #> 4 4 0.06666667 #> 5 5 0.06666667 #> 6 6 0.04166667 #> 7 7 0.04347826 #> 8 8 0.05555556 #> 9 9 0.04166667 #> 10 10 0.04545455 # Add the closeness values to # the graph as a node attribute graph <- graph %>% join_node_attrs( df = get_closeness(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label closeness #> 1 1 1 0.05263158 #> 2 2 2 0.06250000 #> 3 3 3 0.05555556 #> 4 4 4 0.06666667 #> 5 5 5 0.06666667 #> 6 6 6 0.04166667 #> 7 7 7 0.04347826 #> 8 8 8 0.05555556 #> 9 9 9 0.04166667 #> 10 10 10 0.04545455"},{"path":"/reference/get_closeness_vitality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get closeness vitality — get_closeness_vitality","title":"Get closeness vitality — get_closeness_vitality","text":"Get closeness vitality values nodes graph.","code":""},{"path":"/reference/get_closeness_vitality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get closeness vitality — get_closeness_vitality","text":"","code":"get_closeness_vitality(graph)"},{"path":"/reference/get_closeness_vitality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get closeness vitality — get_closeness_vitality","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_closeness_vitality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get closeness vitality — get_closeness_vitality","text":"data frame closeness vitality values nodes.","code":""},{"path":"/reference/get_closeness_vitality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get closeness vitality — get_closeness_vitality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) # Get closeness vitality values # for all nodes in the graph graph %>% get_closeness_vitality() #> id closeness_vitality #> 1 1 32 #> 2 2 118 #> 3 3 36 #> 4 4 60 #> 5 5 0 #> 6 6 48 #> 7 7 46 #> 8 8 30 #> 9 9 48 #> 10 10 44 # Add the closeness vitality # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_closeness_vitality(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label closeness_vitality #> 1 1 1 32 #> 2 2 2 118 #> 3 3 3 36 #> 4 4 4 60 #> 5 5 5 0 #> 6 6 6 48 #> 7 7 7 46 #> 8 8 8 30 #> 9 9 9 48 #> 10 10 10 44"},{"path":"/reference/get_cmty_edge_btwns.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership by edge betweenness — get_cmty_edge_btwns","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"Using edge betweenness, obtain group membership values nodes graph.","code":""},{"path":"/reference/get_cmty_edge_btwns.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"","code":"get_cmty_edge_btwns(graph)"},{"path":"/reference/get_cmty_edge_btwns.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_cmty_edge_btwns.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_edge_btwns.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the group membership # values for all nodes in the # graph through calculation of # the leading non-negative # eigenvector of the modularity # matrix of the graph graph %>% get_cmty_edge_btwns() #> id edge_btwns_group #> 1 1 1 #> 2 2 2 #> 3 3 2 #> 4 4 3 #> 5 5 2 #> 6 6 2 #> 7 7 1 #> 8 8 3 #> 9 9 3 #> 10 10 4 # Add the group membership # values to the graph # as a node attribute graph <- graph %>% join_node_attrs( df = get_cmty_edge_btwns(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label edge_btwns_group #> 1 1 1 1 #> 2 2 2 2 #> 3 3 3 2 #> 4 4 4 3 #> 5 5 5 2 #> 6 6 6 2 #> 7 7 7 1 #> 8 8 8 3 #> 9 9 9 3 #> 10 10 10 4"},{"path":"/reference/get_cmty_fast_greedy.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership by modularity optimization — get_cmty_fast_greedy","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"use greedy optimization modularity score, obtain group membership values nodes graph. Note method works graphs without multiple edges.","code":""},{"path":"/reference/get_cmty_fast_greedy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"","code":"get_cmty_fast_greedy(graph)"},{"path":"/reference/get_cmty_fast_greedy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_cmty_fast_greedy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_fast_greedy.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"","code":"# Create a graph with a # balanced tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Get the group membership # values for all nodes in # the graph through the greedy # optimization of modularity # algorithm graph %>% get_cmty_fast_greedy() #> id f_g_group #> 1 1 1 #> 2 2 2 #> 3 3 1 #> 4 4 2 #> 5 5 2 #> 6 6 1 #> 7 7 1 # Add the group membership # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_cmty_fast_greedy(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label f_g_group #> 1 1 1 1 #> 2 2 2 2 #> 3 3 3 1 #> 4 4 4 2 #> 5 5 5 2 #> 6 6 6 1 #> 7 7 7 1"},{"path":"/reference/get_cmty_l_eigenvec.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"calculation leading non-negative eigenvector modularity matrix graph, obtain group membership values nodes graph.","code":""},{"path":"/reference/get_cmty_l_eigenvec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"","code":"get_cmty_l_eigenvec(graph)"},{"path":"/reference/get_cmty_l_eigenvec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_cmty_l_eigenvec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_l_eigenvec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the group membership # values for all nodes in the # graph through calculation of # the leading non-negative # eigenvector of the modularity # matrix of the graph graph %>% get_cmty_l_eigenvec() #> id l_eigenvec_group #> 1 1 1 #> 2 2 3 #> 3 3 3 #> 4 4 1 #> 5 5 3 #> 6 6 3 #> 7 7 1 #> 8 8 1 #> 9 9 1 #> 10 10 2 # Add the group membership # values to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_cmty_l_eigenvec(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label l_eigenvec_group #> 1 1 1 1 #> 2 2 2 3 #> 3 3 3 3 #> 4 4 4 1 #> 5 5 5 3 #> 6 6 6 3 #> 7 7 7 1 #> 8 8 8 1 #> 9 9 9 1 #> 10 10 10 2"},{"path":"/reference/get_cmty_louvain.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership by Louvain optimization — get_cmty_louvain","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"use multi-level optimization modularity score, obtain group membership values nodes graph.","code":""},{"path":"/reference/get_cmty_louvain.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"","code":"get_cmty_louvain(graph)"},{"path":"/reference/get_cmty_louvain.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_cmty_louvain.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_louvain.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the group membership values # for all nodes in the graph # through the multi-level # optimization of modularity # algorithm graph %>% get_cmty_louvain() #> id louvain_group #> 1 1 1 #> 2 2 2 #> 3 3 2 #> 4 4 3 #> 5 5 2 #> 6 6 2 #> 7 7 1 #> 8 8 3 #> 9 9 3 #> 10 10 4 # Add the group membership # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_cmty_louvain(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label louvain_group #> 1 1 1 1 #> 2 2 2 2 #> 3 3 3 2 #> 4 4 4 3 #> 5 5 5 2 #> 6 6 6 2 #> 7 7 7 1 #> 8 8 8 3 #> 9 9 9 3 #> 10 10 10 4"},{"path":"/reference/get_cmty_walktrap.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership using the Walktrap method — get_cmty_walktrap","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"Walktrap community finding algorithm, obtain group membership values nodes graph.","code":""},{"path":"/reference/get_cmty_walktrap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"","code":"get_cmty_walktrap(graph, steps = 4)"},{"path":"/reference/get_cmty_walktrap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"graph graph object class dgr_graph. steps number steps take random walks.","code":""},{"path":"/reference/get_cmty_walktrap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_walktrap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the group membership # values for all nodes in the # graph through the Walktrap # community finding algorithm graph %>% get_cmty_walktrap() #> id walktrap_group #> 1 1 3 #> 2 2 2 #> 3 3 2 #> 4 4 1 #> 5 5 2 #> 6 6 2 #> 7 7 3 #> 8 8 1 #> 9 9 1 #> 10 10 4 # Add the group membership # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_cmty_walktrap(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label walktrap_group #> 1 1 1 3 #> 2 2 2 2 #> 3 3 3 2 #> 4 4 4 1 #> 5 5 5 2 #> 6 6 6 2 #> 7 7 7 3 #> 8 8 8 1 #> 9 9 9 1 #> 10 10 10 4"},{"path":"/reference/get_common_nbrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get all common neighbors between two or more nodes — get_common_nbrs","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"two nodes, get set common neighboring nodes.","code":""},{"path":"/reference/get_common_nbrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"","code":"get_common_nbrs(graph, nodes)"},{"path":"/reference/get_common_nbrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"graph graph object class dgr_graph. nodes vector node ID values length least 2.","code":""},{"path":"/reference/get_common_nbrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"vector node ID values.","code":""},{"path":"/reference/get_common_nbrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"","code":"# Create a directed graph with 5 nodes graph <- create_graph() %>% add_path(n = 5) # Find all common neighbor nodes # for nodes `1` and `2` (there are no # common neighbors amongst them) graph %>% get_common_nbrs( nodes = c(1, 2)) #> [1] NA # Find all common neighbor nodes for # nodes `1` and `3` graph %>% get_common_nbrs( nodes = c(1, 3)) #> [1] 2"},{"path":"/reference/get_coreness.html","id":null,"dir":"Reference","previous_headings":"","what":"Get coreness values for graph nodes — get_coreness","title":"Get coreness values for graph nodes — get_coreness","text":"Get coreness values nodes graph.","code":""},{"path":"/reference/get_coreness.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get coreness values for graph nodes — get_coreness","text":"","code":"get_coreness(graph, direction = \"all\")"},{"path":"/reference/get_coreness.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get coreness values for graph nodes — get_coreness","text":"graph graph object class dgr_graph. direction using (default), search ignore edge direction traversing graph. , measurements paths node whereas , measurements paths node.","code":""},{"path":"/reference/get_coreness.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get coreness values for graph nodes — get_coreness","text":"data frame coreness values nodes.","code":""},{"path":"/reference/get_coreness.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get coreness values for graph nodes — get_coreness","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get coreness values for # all nodes in the graph graph %>% get_coreness() #> id coreness #> 1 1 3 #> 2 2 3 #> 3 3 2 #> 4 4 3 #> 5 5 3 #> 6 6 3 #> 7 7 3 #> 8 8 2 #> 9 9 2 #> 10 10 0 # Add the coreness values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_coreness(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label coreness #> 1 1 1 3 #> 2 2 2 3 #> 3 3 3 2 #> 4 4 4 3 #> 5 5 5 3 #> 6 6 6 3 #> 7 7 7 3 #> 8 8 8 2 #> 9 9 9 2 #> 10 10 10 0"},{"path":"/reference/get_degree_distribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Get total degree distribution data for a graph — get_degree_distribution","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"Get degree distribution data graph. Graph degree represented frequency total degree values nodes graph.","code":""},{"path":"/reference/get_degree_distribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"","code":"get_degree_distribution(graph, mode = \"total\")"},{"path":"/reference/get_degree_distribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"graph graph object class dgr_graph. mode using total (default), degree considered node total degree. degree used -degree -degree, respectively.","code":""},{"path":"/reference/get_degree_distribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"data frame degree frequencies.","code":""},{"path":"/reference/get_degree_distribution.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the total degree # distribution for the graph graph %>% get_degree_distribution( mode = \"total\") #> degree total_degree_dist #> 1 0 0.1 #> 2 1 0.0 #> 3 2 0.2 #> 4 3 0.4 #> 5 4 0.1 #> 6 5 0.2"},{"path":"/reference/get_degree_histogram.html","id":null,"dir":"Reference","previous_headings":"","what":"Get histogram data for a graph's degree frequency — get_degree_histogram","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"Get histogram data graph's degree frequency. bin width set 1 zero-value degrees omitted output.","code":""},{"path":"/reference/get_degree_histogram.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"","code":"get_degree_histogram(graph, mode = \"total\")"},{"path":"/reference/get_degree_histogram.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"graph graph object class dgr_graph. mode using total (default), degree considered node total degree. degree used -degree -degree, respectively.","code":""},{"path":"/reference/get_degree_histogram.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"data frame degree counts.","code":""},{"path":"/reference/get_degree_histogram.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get degree histogram data for # the graph (reporting total degree) graph %>% get_degree_histogram( mode = \"total\") #> degree total_degree_hist #> 1 0 1 #> 2 1 0 #> 3 2 2 #> 4 3 4 #> 5 4 1 #> 6 5 2"},{"path":"/reference/get_degree_in.html","id":null,"dir":"Reference","previous_headings":"","what":"Get indegree values for all nodes — get_degree_in","title":"Get indegree values for all nodes — get_degree_in","text":"Get indegree values nodes graph.","code":""},{"path":"/reference/get_degree_in.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get indegree values for all nodes — get_degree_in","text":"","code":"get_degree_in(graph, normalized = FALSE)"},{"path":"/reference/get_degree_in.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get indegree values for all nodes — get_degree_in","text":"graph graph object class dgr_graph. normalized set FALSE (default), indegree provided nodes (count edges node). set TRUE, result node divided total number nodes graph minus 1.","code":""},{"path":"/reference/get_degree_in.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get indegree values for all nodes — get_degree_in","text":"data frame indegree values nodes.","code":""},{"path":"/reference/get_degree_in.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get indegree values for all nodes — get_degree_in","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the indegree values for # all nodes in the graph graph %>% get_degree_in() #> id indegree #> 1 1 3 #> 2 2 3 #> 3 3 2 #> 4 4 5 #> 5 5 4 #> 6 6 5 #> 7 7 3 #> 8 8 2 #> 9 9 3 #> 10 10 0 # Add the indegree values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_degree_in(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label indegree #> 1 1 1 3 #> 2 2 2 3 #> 3 3 3 2 #> 4 4 4 5 #> 5 5 5 4 #> 6 6 6 5 #> 7 7 7 3 #> 8 8 8 2 #> 9 9 9 3 #> 10 10 10 0"},{"path":"/reference/get_degree_out.html","id":null,"dir":"Reference","previous_headings":"","what":"Get outdegree values for all nodes — get_degree_out","title":"Get outdegree values for all nodes — get_degree_out","text":"Get outdegree values nodes graph.","code":""},{"path":"/reference/get_degree_out.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get outdegree values for all nodes — get_degree_out","text":"","code":"get_degree_out(graph, normalized = FALSE)"},{"path":"/reference/get_degree_out.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get outdegree values for all nodes — get_degree_out","text":"graph graph object class dgr_graph. normalized set FALSE (default), outdegree provided nodes (count edges outgoing node). set TRUE, result node divided total number nodes graph minus 1.","code":""},{"path":"/reference/get_degree_out.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get outdegree values for all nodes — get_degree_out","text":"data frame outdegree values nodes.","code":""},{"path":"/reference/get_degree_out.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get outdegree values for all nodes — get_degree_out","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the outdegree values # for all nodes in the graph graph %>% get_degree_out() #> id outdegree #> 1 1 3 #> 2 2 3 #> 3 3 2 #> 4 4 5 #> 5 5 4 #> 6 6 5 #> 7 7 3 #> 8 8 2 #> 9 9 3 #> 10 10 0 # Add the outdegree values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_degree_out(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label outdegree #> 1 1 1 3 #> 2 2 2 3 #> 3 3 3 2 #> 4 4 4 5 #> 5 5 5 4 #> 6 6 6 5 #> 7 7 7 3 #> 8 8 8 2 #> 9 9 9 3 #> 10 10 10 0"},{"path":"/reference/get_degree_total.html","id":null,"dir":"Reference","previous_headings":"","what":"Get total degree values for all nodes — get_degree_total","title":"Get total degree values for all nodes — get_degree_total","text":"Get total degree values nodes graph.","code":""},{"path":"/reference/get_degree_total.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get total degree values for all nodes — get_degree_total","text":"","code":"get_degree_total(graph, normalized = FALSE)"},{"path":"/reference/get_degree_total.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get total degree values for all nodes — get_degree_total","text":"graph graph object class dgr_graph. normalized set FALSE (default), total degree provided nodes (count edges node). set TRUE, result node divided total number nodes graph minus 1.","code":""},{"path":"/reference/get_degree_total.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get total degree values for all nodes — get_degree_total","text":"data frame total degree values nodes.","code":""},{"path":"/reference/get_degree_total.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get total degree values for all nodes — get_degree_total","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the total degree values # for all nodes in the graph graph %>% get_degree_total() #> id total_degree #> 1 1 3 #> 2 2 3 #> 3 3 2 #> 4 4 5 #> 5 5 4 #> 6 6 5 #> 7 7 3 #> 8 8 2 #> 9 9 3 #> 10 10 0 # Add the total degree values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_degree_total(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label total_degree #> 1 1 1 3 #> 2 2 2 3 #> 3 3 3 2 #> 4 4 4 5 #> 5 5 5 4 #> 6 6 6 5 #> 7 7 7 3 #> 8 8 8 2 #> 9 9 9 3 #> 10 10 10 0"},{"path":"/reference/get_dice_similarity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Dice similarity coefficient scores — get_dice_similarity","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"Get Dice similarity coefficient scores one nodes graph.","code":""},{"path":"/reference/get_dice_similarity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"","code":"get_dice_similarity(graph, nodes = NULL, direction = \"all\", round_to = 3)"},{"path":"/reference/get_dice_similarity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"graph graph object class dgr_graph. nodes optional vector node IDs consider Dice similarity scores. supplied, similarity scores provided every pair nodes graph. direction using (default), function ignore edge direction determining scores neighboring nodes. , edge direction neighboring nodes considered. round_to maximum number decimal places retain Dice similarity coefficient scores. default value 3.","code":""},{"path":"/reference/get_dice_similarity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"matrix Dice similarity values pair nodes considered.","code":""},{"path":"/reference/get_dice_similarity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the Dice similarity # values for nodes `5`, `6`, # and `7` graph %>% get_dice_similarity( nodes = 5:7) #> 5 6 7 #> 5 1.000 0.444 0.571 #> 6 0.444 1.000 0.500 #> 7 0.571 0.500 1.000"},{"path":"/reference/get_eccentricity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node eccentricities — get_eccentricity","title":"Get node eccentricities — get_eccentricity","text":"Get data frame node eccentricity values.","code":""},{"path":"/reference/get_eccentricity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node eccentricities — get_eccentricity","text":"","code":"get_eccentricity(graph, mode = \"out\")"},{"path":"/reference/get_eccentricity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node eccentricities — get_eccentricity","text":"graph graph object class dgr_graph. mode mode shortest paths given vertices calculated directed graphs. (default) shortest paths node, shortest paths node considered. used, corresponding undirected graph used edge directions ignored. undirected graphs, argument ignored.","code":""},{"path":"/reference/get_eccentricity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node eccentricities — get_eccentricity","text":"data frame containing eccentricity values node ID value.","code":""},{"path":"/reference/get_eccentricity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node eccentricities — get_eccentricity","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the eccentricity values for # all nodes in the graph graph %>% get_eccentricity() #> id eccentricity #> 1 1 2 #> 2 2 3 #> 3 3 3 #> 4 4 2 #> 5 5 3 #> 6 6 2 #> 7 7 3 #> 8 8 3 #> 9 9 2 #> 10 10 0"},{"path":"/reference/get_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get edge attribute values — get_edge_attrs","title":"Get edge attribute values — get_edge_attrs","text":"graph object class dgr_graph, get edge attribute values one edges.","code":""},{"path":"/reference/get_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get edge attribute values — get_edge_attrs","text":"","code":"get_edge_attrs(graph, edge_attr, from = NULL, to = NULL)"},{"path":"/reference/get_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get edge attribute values — get_edge_attrs","text":"graph graph object class dgr_graph. edge_attr name attribute get values. optional vector node IDs edge outgoing filtering list edges. optional vector node IDs edge incoming filtering list edges.","code":""},{"path":"/reference/get_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get edge attribute values — get_edge_attrs","text":"named vector edge attribute values attribute given edge_attr edge.","code":""},{"path":"/reference/get_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get edge attribute values — get_edge_attrs","text":"","code":"# Create a simple graph where # edges have an edge attribute # named `value` graph <- create_graph() %>% add_n_nodes(n = 4) %>% { edges <- create_edge_df( from = c(1, 2, 1, 4), to = c(2, 3, 4, 3), rel = \"rel\") add_edge_df( graph = ., edge_df = edges) } %>% set_edge_attrs( edge_attr = value, values = 1.6, from = 1, to = 2) %>% set_edge_attrs( edge_attr = value, values = 4.3, from = 1, to = 4) %>% set_edge_attrs( edge_attr = value, values = 2.9, from = 2, to = 3) %>% set_edge_attrs( edge_attr = value, values = 8.4, from = 4, to = 3) # Get the values for the # `value` edge attribute graph %>% get_edge_attrs( edge_attr = value) #> 1->2 2->3 1->4 4->3 #> 1.6 2.9 4.3 8.4 # To only return edge attribute # values for specified edges, use # the `from` and `to` arguments graph %>% get_edge_attrs( edge_attr = value, from = c(1, 2), to = c(2, 3)) #> 1->2 2->3 #> 1.6 2.9"},{"path":"/reference/get_edge_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"graph object class dgr_graph, get edge attribute values one edges. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/get_edge_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"","code":"get_edge_attrs_ws(graph, edge_attr)"},{"path":"/reference/get_edge_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"graph graph object class dgr_graph. edge_attr name attribute get values.","code":""},{"path":"/reference/get_edge_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"named vector edge attribute values attribute given edge_attr edge.","code":""},{"path":"/reference/get_edge_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"","code":"# Create a simple graph where # edges have an edge attribute # named `value` graph <- create_graph() %>% add_n_nodes(n = 4) %>% { edges <- create_edge_df( from = c(1, 2, 1, 4), to = c(2, 3, 4, 3), rel = \"rel\") add_edge_df( graph = ., edge_df = edges) } %>% set_edge_attrs( edge_attr = value, values = 1.6, from = 1, to = 2) %>% set_edge_attrs( edge_attr = value, values = 4.3, from = 1, to = 4) %>% set_edge_attrs( edge_attr = value, values = 2.9, from = 2, to = 3) %>% set_edge_attrs( edge_attr = value, values = 8.4, from = 4, to = 3) # Select the edges defined as # `1`->`3` and `2`->`3` graph <- graph %>% select_edges( from = c(1, 2), to = c(2, 3)) # Get the edge attribute values # for the `value` attribute, limited # to the current edge selection graph %>% get_edge_attrs_ws( edge_attr = value) #> 1->2 2->3 #> 1.6 2.9"},{"path":"/reference/get_edge_count_w_multiedge.html","id":null,"dir":"Reference","previous_headings":"","what":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"Get count number edge definitions (e.g, 1 -> 2) multiple edges (.e., 1 edge definition, distinct edge ID values). , example, 2 edge definitions graph involve 6 separate edge IDs (3 edge IDs pairs nodes), count 2.","code":""},{"path":"/reference/get_edge_count_w_multiedge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"","code":"get_edge_count_w_multiedge(graph)"},{"path":"/reference/get_edge_count_w_multiedge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_edge_count_w_multiedge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"vector single, numerical value.","code":""},{"path":"/reference/get_edge_count_w_multiedge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 5, label = TRUE) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 4, 4, 3, 5, 1, 3, 4), to = c(4, 1, 1, 2, 2, 2, 2, 1)) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get the total number of edge # definitions (e.g., `4` -> `1`) where # there are multiple edges (i.e., # distinct edges with separate edge # ID values) graph %>% get_edge_count_w_multiedge() #> [1] 2"},{"path":"/reference/get_edge_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Get an edge data frame from a graph — get_edge_df","title":"Get an edge data frame from a graph — get_edge_df","text":"graph, obtain edge data frame current edge attributes.","code":""},{"path":"/reference/get_edge_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get an edge data frame from a graph — get_edge_df","text":"","code":"get_edge_df(graph)"},{"path":"/reference/get_edge_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get an edge data frame from a graph — get_edge_df","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_edge_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get an edge data frame from a graph — get_edge_df","text":"edge data frame.","code":""},{"path":"/reference/get_edge_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get an edge data frame from a graph — get_edge_df","text":"","code":"# Create a graph graph <- create_graph() %>% add_n_nodes( n = 1, type = \"a\") %>% select_last_nodes_created() %>% add_n_nodes_ws( n = 5, direction = \"from\", type = \"b\") %>% select_edges_by_node_id( nodes = 3:5) %>% set_edge_attrs_ws( edge_attr = color, value = \"green\") %>% set_edge_attrs_ws( edge_attr = rel, value = \"a\") %>% invert_selection %>% set_edge_attrs_ws( edge_attr = color, value = \"blue\") %>% set_edge_attrs_ws( edge_attr = rel, value = \"b\") %>% clear_selection() # Get the graph's internal # edge data frame (edf) graph %>% get_edge_df() #> id from to rel color #> 1 1 1 2 b blue #> 2 2 1 3 a green #> 3 3 1 4 a green #> 4 4 1 5 a green #> 5 5 1 6 b blue"},{"path":"/reference/get_edge_df_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"graph object class dgr_graph, get graph's internal edge data frame filtered edge ID values currently active selection. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/get_edge_df_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"","code":"get_edge_df_ws(graph)"},{"path":"/reference/get_edge_df_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_edge_df_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"edge data frame.","code":""},{"path":"/reference/get_edge_df_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_edge_attrs( edge_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # Select edges with ID values # `1` and `3` graph <- graph %>% select_edges_by_edge_id( edges = c(1, 3)) # Get the edge data frame that's # limited to the rows that correspond # to the edge selection graph %>% get_edge_df_ws() #> id from to rel value #> 1 1 2 1 2.5 #> 2 3 3 2 4.2"},{"path":"/reference/get_edge_ids.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a vector of edge ID values — get_edge_ids","title":"Get a vector of edge ID values — get_edge_ids","text":"Obtain vector edge ID values graph object. optional filter edge attribute can limit set edge ID values returned.","code":""},{"path":"/reference/get_edge_ids.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a vector of edge ID values — get_edge_ids","text":"","code":"get_edge_ids(graph, conditions = NULL)"},{"path":"/reference/get_edge_ids.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a vector of edge ID values — get_edge_ids","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval edges.","code":""},{"path":"/reference/get_edge_ids.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a vector of edge ID values — get_edge_ids","text":"vector edge ID values.","code":""},{"path":"/reference/get_edge_ids.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a vector of edge ID values — get_edge_ids","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"letter\", color = c(\"red\", \"green\", \"grey\", \"blue\"), value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\", color = c(\"pink\", \"blue\", \"blue\"), value = c(3.9, 2.5, 7.3)) # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get a vector of all edges in a graph graph %>% get_edge_ids() #> [1] 1 2 3 # Get a vector of edge ID values using a # numeric comparison (i.e., all edges with # `value` attribute greater than 3) get_edge_ids( graph, conditions = value > 3) #> [1] 1 3 # Get a vector of edge ID values using # a match pattern (i.e., all edges with # `color` attribute of `pink`) get_edge_ids( graph, conditions = color == \"pink\") #> [1] 1 # Use multiple conditions to return edges # with the desired attribute values get_edge_ids( graph, conditions = color == \"blue\" & value > 5) #> [1] 3"},{"path":"/reference/get_edge_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get detailed information on edges — get_edge_info","title":"Get detailed information on edges — get_edge_info","text":"Obtain data frame detailed information edges interrelationships within graph.","code":""},{"path":"/reference/get_edge_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get detailed information on edges — get_edge_info","text":"","code":"get_edge_info(graph)"},{"path":"/reference/get_edge_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get detailed information on edges — get_edge_info","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_edge_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get detailed information on edges — get_edge_info","text":"data frame containing information specific edge within graph.","code":""},{"path":"/reference/get_edge_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get detailed information on edges — get_edge_info","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) # Get information on the # graph's edges graph %>% get_edge_info() #> id from to rel #> 1 1 1 3 #> 2 2 2 1 #> 3 3 2 5 #> 4 4 2 3 #> 5 5 3 1 #> 6 6 3 2 #> 7 7 3 5 #> 8 8 3 4 #> 9 9 4 1 #> 10 10 5 4 "},{"path":"/reference/get_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node IDs associated with edges — get_edges","title":"Get node IDs associated with edges — get_edges","text":"Obtain vector, data frame, list node IDs associated edges graph object. optional filter edge attribute can limit set edges returned.","code":""},{"path":"/reference/get_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node IDs associated with edges — get_edges","text":"","code":"get_edges( graph, conditions = NULL, return_type = \"vector\", return_values = \"id\" )"},{"path":"/reference/get_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node IDs associated with edges — get_edges","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval edges. return_type using vector (default), vector character objects representing edges provided. list list object provided contains vectors outgoing incoming node IDs associated edges. df, data frame containing outgoing incoming node IDs associated edges. return_values using id (default) results node ID values returned edge definitions. label, node labels instead used define edges.","code":""},{"path":"/reference/get_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node IDs associated with edges — get_edges","text":"list, data frame, vector object, depending value given return_type.","code":""},{"path":"/reference/get_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node IDs associated with edges — get_edges","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, label = c(\"one\", \"two\", \"three\", \"four\"), type = \"letter\", color = c(\"red\", \"green\", \"grey\", \"blue\"), value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\", color = c(\"pink\", \"blue\", \"blue\"), value = c(3.9, 2.5, 7.3)) # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get all edges within a graph, returned as a list graph %>% get_edges( return_type = \"vector\") #> [1] \"1->4\" \"2->3\" \"3->1\" # Get all edges within a graph, returned as a # data frame graph %>% get_edges( return_type = \"df\") #> from to #> 1 1 4 #> 2 2 3 #> 3 3 1 # Get all edges returned as a list graph %>% get_edges( return_type = \"list\") #> [[1]] #> [1] 1 2 3 #> #> [[2]] #> [1] 4 3 1 #> # Get a vector of edges using # a numeric comparison (i.e., # all edges with a `value` # attribute greater than 3) graph %>% get_edges( conditions = value > 3, return_type = \"vector\") #> [1] \"1->4\" \"3->1\" # Get a vector of edges using # a matching condition graph %>% get_edges( conditions = color == \"pink\", return_type = \"vector\") #> [1] \"1->4\" # Use multiple conditions to # return edges with the # desired attribute values graph %>% get_edges( conditions = color == \"blue\" & value > 3, return_type = \"vector\") #> [1] \"3->1\" # Use `return_values = \"label\"` # to return the labels of the # connected nodes graph %>% get_edges( conditions = color == \"blue\" & value > 3, return_type = \"vector\", return_values = \"label\") #> [1] \"three->one\""},{"path":"/reference/get_eigen_centrality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the eigen centrality for all nodes — get_eigen_centrality","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"Get eigen centrality values nodes graph.","code":""},{"path":"/reference/get_eigen_centrality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"","code":"get_eigen_centrality(graph, weights_attr = NULL)"},{"path":"/reference/get_eigen_centrality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"graph graph object class dgr_graph. weights_attr optional name edge attribute use adjacency matrix. NULL , exists, weight edge attribute graph used. NA edge weights used.","code":""},{"path":"/reference/get_eigen_centrality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"data frame eigen centrality scores nodes.","code":""},{"path":"/reference/get_eigen_centrality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the eigen centrality scores # for nodes in the graph graph %>% get_eigen_centrality() #> id eigen_centrality #> 1 1 0.6640 #> 2 2 0.6767 #> 3 3 0.4988 #> 4 4 0.9541 #> 5 5 0.7908 #> 6 6 1.0000 #> 7 7 0.6391 #> 8 8 0.4524 #> 9 9 0.6702 #> 10 10 0.0000"},{"path":"/reference/get_girth.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph girth — get_girth","title":"Get the graph girth — get_girth","text":"Get girth graph, length shortest circle graph. Loop edges multiple edges considered. graph contains cycles zero returned.","code":""},{"path":"/reference/get_girth.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph girth — get_girth","text":"","code":"get_girth(graph)"},{"path":"/reference/get_girth.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph girth — get_girth","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_girth.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph girth — get_girth","text":"single numeric value representing length shortest circle graph.","code":""},{"path":"/reference/get_girth.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph girth — get_girth","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the graph's girth graph %>% get_girth() #> [1] 5 # Create a full graph and then # get the girth for that create_graph() %>% add_full_graph(n = 10) %>% get_girth() #> [1] 3"},{"path":"/reference/get_global_graph_attr_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get global graph attributes — get_global_graph_attr_info","title":"Get global graph attributes — get_global_graph_attr_info","text":"Get available global attributes graph object class dgr_graph.","code":""},{"path":"/reference/get_global_graph_attr_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get global graph attributes — get_global_graph_attr_info","text":"","code":"get_global_graph_attr_info(graph)"},{"path":"/reference/get_global_graph_attr_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get global graph attributes — get_global_graph_attr_info","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_global_graph_attr_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get global graph attributes — get_global_graph_attr_info","text":"data frame containing global attributes graph.","code":""},{"path":"/reference/get_global_graph_attr_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get global graph attributes — get_global_graph_attr_info","text":"","code":"# Create a new, empty graph graph <- create_graph() # View the graph's set of # global attributes graph %>% get_global_graph_attr_info() #> # A tibble: 17 × 3 #> attr value attr_type #> #> 1 layout neato graph #> 2 outputorder edgesfirst graph #> 3 bgcolor white graph #> 4 fontname Helvetica node #> 5 fontsize 10 node #> 6 shape circle node #> 7 fixedsize true node #> 8 width 0.5 node #> 9 style filled node #> 10 fillcolor aliceblue node #> 11 color gray70 node #> 12 fontcolor gray50 node #> 13 fontname Helvetica edge #> 14 fontsize 8 edge #> 15 len 1.5 edge #> 16 color gray80 edge #> 17 arrowsize 0.5 edge"},{"path":"/reference/get_graph_actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Get information on any available graph actions — get_graph_actions","title":"Get information on any available graph actions — get_graph_actions","text":"Get tibble available graph actions, contains information function invocations called graph every transformation step, , manually invoked trigger_graph_actions() function.","code":""},{"path":"/reference/get_graph_actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get information on any available graph actions — get_graph_actions","text":"","code":"get_graph_actions(graph)"},{"path":"/reference/get_graph_actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get information on any available graph actions — get_graph_actions","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get information on any available graph actions — get_graph_actions","text":"df_tbl object.","code":""},{"path":"/reference/get_graph_actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get information on any available graph actions — get_graph_actions","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Add a graph action that sets a node # attr column with a function; the # main function `set_node_attr_w_fcn()` # uses the `get_betweenness()` function # to provide betweenness values in the # `btwns` column graph <- graph %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_betweenness\", column_name = \"btwns\", action_name = \"get_btwns\") # To ensure that the action is # available in the graph, use the # `get_graph_actions()` function graph %>% get_graph_actions() #> # A tibble: 1 × 3 #> action_index action_name expression #> #> 1 1 get_btwns set_node_attr_w_fcn(graph = graph, node_attr_fcn = '…"},{"path":"/reference/get_graph_from_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a graph available in a series — get_graph_from_graph_series","title":"Get a graph available in a series — get_graph_from_graph_series","text":"Using graph series object type dgr_graph_1D, get graph object.","code":""},{"path":"/reference/get_graph_from_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a graph available in a series — get_graph_from_graph_series","text":"","code":"get_graph_from_graph_series(graph_series, graph_no)"},{"path":"/reference/get_graph_from_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a graph available in a series — get_graph_from_graph_series","text":"graph_series graph series object type dgr_graph_1D. graph_no index graph graph series.","code":""},{"path":"/reference/get_graph_from_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a graph available in a series — get_graph_from_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Get the second graph in the series extracted_graph <- series %>% get_graph_from_graph_series( graph_no = 2)"},{"path":"/reference/get_graph_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get metrics for a graph — get_graph_info","title":"Get metrics for a graph — get_graph_info","text":"Get data frame metrics graph.","code":""},{"path":"/reference/get_graph_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get metrics for a graph — get_graph_info","text":"","code":"get_graph_info(graph)"},{"path":"/reference/get_graph_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get metrics for a graph — get_graph_info","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get metrics for a graph — get_graph_info","text":"data frame containing metrics pertaining graph","code":""},{"path":"/reference/get_graph_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get metrics for a graph — get_graph_info","text":"","code":"if (FALSE) { # Import a GML graph file available # in the DiagrammeR package karate_club <- system.file( \"extdata\", \"karate.gml\", package = \"DiagrammeR\") %>% import_graph() %>% set_graph_name(\"karate\") # Display a data frame with # graph information karate_club %>% get_graph_info() }"},{"path":"/reference/get_graph_log.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph log information — get_graph_log","title":"Get the graph log information — get_graph_log","text":"Get tibble graph log, contains information functions called graph resulted transformation graph.","code":""},{"path":"/reference/get_graph_log.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph log information — get_graph_log","text":"","code":"get_graph_log(graph)"},{"path":"/reference/get_graph_log.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph log information — get_graph_log","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_log.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph log information — get_graph_log","text":"df_tbl object.","code":""},{"path":"/reference/get_graph_log.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph log information — get_graph_log","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function and # delete 2 nodes from the graph graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) %>% delete_node(node = 5) %>% delete_node(node = 7) # Get the graph log, which is a # record of all graph transformations graph %>% get_graph_log() #> # A tibble: 4 × 8 #> version_id function_used time_modified duration nodes edges d_n d_e #> #> 1 1 create_graph 2023-11-08 15:33:54 0.00279 0 0 0 0 #> 2 2 add_gnm_graph 2023-11-08 15:33:54 0.0106 10 15 10 15 #> 3 3 delete_node 2023-11-08 15:33:54 0.0139 9 11 -1 -4 #> 4 4 delete_node 2023-11-08 15:33:54 0.0171 8 8 -1 -3"},{"path":"/reference/get_graph_name.html","id":null,"dir":"Reference","previous_headings":"","what":"Get graph name — get_graph_name","title":"Get graph name — get_graph_name","text":"Get name graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_name.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get graph name — get_graph_name","text":"","code":"get_graph_name(graph)"},{"path":"/reference/get_graph_name.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get graph name — get_graph_name","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_name.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get graph name — get_graph_name","text":"single-length character vector assigned graph name. graph name set, NA returned.","code":""},{"path":"/reference/get_graph_name.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get graph name — get_graph_name","text":"","code":"# Create an empty graph graph <- create_graph() # Provide the new graph with a name graph <- set_graph_name( graph, name = \"the_name\") # Get the graph's name graph %>% get_graph_name() #> [1] \"the_name\""},{"path":"/reference/get_graph_series_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get information on a graph series — get_graph_series_info","title":"Get information on a graph series — get_graph_series_info","text":"Obtain data frame information graphs within graph series.","code":""},{"path":"/reference/get_graph_series_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get information on a graph series — get_graph_series_info","text":"","code":"get_graph_series_info(graph_series)"},{"path":"/reference/get_graph_series_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get information on a graph series — get_graph_series_info","text":"graph_series graph series object type dgr_graph_1D.","code":""},{"path":"/reference/get_graph_series_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get information on a graph series — get_graph_series_info","text":"data frame containing information graphs within supplied graph series.","code":""},{"path":"/reference/get_graph_series_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get information on a graph series — get_graph_series_info","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Get information on the graphs in the series series %>% get_graph_series_info() #> graph name date_time tz nodes edges directed #> 1 1 graph_SVUyR63K 2023-11-08 15:33:55 UTC 4 3 TRUE #> 2 2 graph_SueySz3B 2023-11-08 15:33:55 UTC 5 5 TRUE #> 3 3 graph_HYG7a9jw 2023-11-08 15:33:55 UTC 6 5 TRUE"},{"path":"/reference/get_graph_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph date-time or timezone — get_graph_time","title":"Get the graph date-time or timezone — get_graph_time","text":"Get time timezone graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph date-time or timezone — get_graph_time","text":"","code":"get_graph_time(graph)"},{"path":"/reference/get_graph_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph date-time or timezone — get_graph_time","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph date-time or timezone — get_graph_time","text":"single-length POSIXct vector assigned graph time.","code":""},{"path":"/reference/get_graph_time.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph date-time or timezone — get_graph_time","text":"","code":"# Create an empty graph and # set the graph's time; if nothing # is supplied for the `tz` argument, # `GMT` is used as the time zone graph <- create_graph() %>% set_graph_time( time = \"2015-10-25 15:23:00\") # Get the graph's time as a POSIXct # object using `get_graph_time()` graph %>% get_graph_time() #> [1] \"2015-10-25 15:23:00 UTC\""},{"path":"/reference/get_jaccard_similarity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"Get Jaccard similarity coefficient scores one nodes graph.","code":""},{"path":"/reference/get_jaccard_similarity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"","code":"get_jaccard_similarity(graph, nodes = NULL, direction = \"all\", round_to = 3)"},{"path":"/reference/get_jaccard_similarity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"graph graph object class dgr_graph. nodes optional vector node IDs consider Jaccard similarity scores. supplied, similarity scores provided every pair nodes graph. direction Using (default), function ignore edge direction determining scores neighboring nodes. , edge direction neighboring nodes considered. round_to maximum number decimal places retain Jaccard similarity coefficient scores. default value 3.","code":""},{"path":"/reference/get_jaccard_similarity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"matrix Jaccard similarity values pair nodes considered.","code":""},{"path":"/reference/get_jaccard_similarity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the Jaccard similarity # values for nodes `5`, `6`, # and `7` graph %>% get_jaccard_similarity( nodes = 5:7) #> 5 6 7 #> 5 1.000 0.286 0.400 #> 6 0.286 1.000 0.333 #> 7 0.400 0.333 1.000"},{"path":"/reference/get_last_edges_created.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the last set of edges created in a graph — get_last_edges_created","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"Get last edges created graph object class dgr_graph. function ideally used just creating edges.","code":""},{"path":"/reference/get_last_edges_created.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"","code":"get_last_edges_created(graph)"},{"path":"/reference/get_last_edges_created.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_last_edges_created.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"vector edge ID values.","code":""},{"path":"/reference/get_last_edges_created.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"","code":"# Create a graph and add a cycle and then # a tree in 2 separate function calls graph <- create_graph() %>% add_cycle( n = 3, rel = \"a\") %>% add_balanced_tree( k = 2, h = 2, rel = \"b\") # Get the last edges created (all edges # from the tree) graph %>% get_last_edges_created() #> [1] 4 5 6 7 8 9"},{"path":"/reference/get_last_nodes_created.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the last set of nodes created in a graph — get_last_nodes_created","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"Get last nodes created graph object class dgr_graph. Provides vector node ID values. function ideally used just creating nodes.","code":""},{"path":"/reference/get_last_nodes_created.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"","code":"get_last_nodes_created(graph)"},{"path":"/reference/get_last_nodes_created.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_last_nodes_created.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"vector node ID values.","code":""},{"path":"/reference/get_last_nodes_created.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"","code":"# Create a graph and add 4 nodes # in 2 separate function calls graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"a_1\", \"a_2\")) %>% add_n_nodes( n = 2, type = \"b\", label = c(\"b_1\", \"b_2\")) # Get the last nodes created (2 nodes # from the last function call) graph %>% get_last_nodes_created() #> [1] 3 4"},{"path":"/reference/get_leverage_centrality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get leverage centrality — get_leverage_centrality","title":"Get leverage centrality — get_leverage_centrality","text":"Get leverage centrality values nodes graph. Leverage centrality measure relationship degree given node degree neighbors, averaged neighbors. node negative leverage centrality influenced neighbors, neighbors connect interact far nodes. node positive leverage centrality influences neighbors since neighbors tend far fewer connections.","code":""},{"path":"/reference/get_leverage_centrality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get leverage centrality — get_leverage_centrality","text":"","code":"get_leverage_centrality(graph)"},{"path":"/reference/get_leverage_centrality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get leverage centrality — get_leverage_centrality","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_leverage_centrality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get leverage centrality — get_leverage_centrality","text":"data frame leverage centrality values nodes.","code":""},{"path":"/reference/get_leverage_centrality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get leverage centrality — get_leverage_centrality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get leverage centrality values # for all nodes in the graph graph %>% get_leverage_centrality() #> id leverage_centrality #> 1 1 -0.1964 #> 2 2 -0.1964 #> 3 3 -0.3810 #> 4 4 0.0556 #> 5 5 -0.0556 #> 6 6 0.0556 #> 7 7 -0.1964 #> 8 8 -0.3810 #> 9 9 -0.1964 #> 10 10 -1.0000 # Add the leverage centrality # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_leverage_centrality(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label leverage_centrality #> 1 1 1 -0.1964 #> 2 2 2 -0.1964 #> 3 3 3 -0.3810 #> 4 4 4 0.0556 #> 5 5 5 -0.0556 #> 6 6 6 0.0556 #> 7 7 7 -0.1964 #> 8 8 8 -0.3810 #> 9 9 9 -0.1964 #> 10 10 10 -1.0000"},{"path":"/reference/get_max_eccentricity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the maximum graph eccentricity — get_max_eccentricity","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"Get diameter graph, largest eccentricity graph. graph eccentricity node shortest path farthest node graph.","code":""},{"path":"/reference/get_max_eccentricity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"","code":"get_max_eccentricity(graph)"},{"path":"/reference/get_max_eccentricity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_max_eccentricity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"single numeric value representing maximum eccentricity graph.","code":""},{"path":"/reference/get_max_eccentricity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the graph's maximum # eccentricity graph %>% get_max_eccentricity() #> [1] 4 # Create a full graph and then # get the maximum eccentricity # value for that create_graph() %>% add_full_graph(n = 10) %>% get_max_eccentricity() #> [1] 1"},{"path":"/reference/get_mean_distance.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the mean distance — get_mean_distance","title":"Get the mean distance — get_mean_distance","text":"Get mean distance graph, average path length graph. operates calculation shortest paths pairs nodes.","code":""},{"path":"/reference/get_mean_distance.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the mean distance — get_mean_distance","text":"","code":"get_mean_distance(graph)"},{"path":"/reference/get_mean_distance.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the mean distance — get_mean_distance","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_mean_distance.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the mean distance — get_mean_distance","text":"single numeric value representing mean distance graph.","code":""},{"path":"/reference/get_mean_distance.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the mean distance — get_mean_distance","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the mean distance graph %>% get_mean_distance() #> [1] 2.5 # Create a full graph and then # get the mean distance value create_graph() %>% add_full_graph(n = 10) %>% get_mean_distance() #> [1] 1"},{"path":"/reference/get_min_cut_between.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the minimum cut between source and sink nodes — get_min_cut_between","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"Get minimum cut source sink nodes. minimum total capacity edges needed removal order eliminate paths source sink nodes.","code":""},{"path":"/reference/get_min_cut_between.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"","code":"get_min_cut_between(graph, from, to)"},{"path":"/reference/get_min_cut_between.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"graph graph object class dgr_graph. node ID source node. node ID sink target node.","code":""},{"path":"/reference/get_min_cut_between.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"single numeric value representing minimum total edge capacity removed disconnect source sink nodes.","code":""},{"path":"/reference/get_min_cut_between.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the minimum cut # between nodes `1` and `4` graph %>% get_min_cut_between( from = 1, to = 2) #> [1] 1 # Create a cycle graph with # randomized values given to all # edges as the `capacity` attribute graph_capacity <- create_graph() %>% add_cycle(n = 5) %>% select_edges() %>% set_edge_attrs_ws( edge_attr = capacity, value = rnorm( n = count_edges(.), mean = 5, sd = 1)) %>% clear_selection() # Determine the minimum cut # between nodes `1` and `4` for # this graph, where `capacity`is # set as an edge attribute graph_capacity %>% get_min_cut_between( from = 1, to = 2) #> [1] 4.479822 # Create a full graph and then # get the minimum cut requirement # between nodes `2` and `8` create_graph() %>% add_full_graph(n = 10) %>% get_min_cut_between( from = 2, to = 8) #> [1] 9"},{"path":"/reference/get_min_eccentricity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the minimum graph eccentricity — get_min_eccentricity","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"Get radius graph, smallest eccentricity graph. graph eccentricity node shortest path farthest node graph.","code":""},{"path":"/reference/get_min_eccentricity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"","code":"get_min_eccentricity(graph, direction = \"all\")"},{"path":"/reference/get_min_eccentricity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"graph graph object class dgr_graph. direction Using (default), search ignore edge direction traversing graph. , measurements paths node whereas , measurements paths node.","code":""},{"path":"/reference/get_min_eccentricity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"single numeric value representing minimum eccentricity graph.","code":""},{"path":"/reference/get_min_eccentricity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the graph's minimum # eccentricity graph %>% get_min_eccentricity() #> [1] 2 # Create a full graph and then # get the minimum eccentricity # value for that create_graph() %>% add_full_graph(n = 10) %>% get_min_eccentricity() #> [1] 1"},{"path":"/reference/get_multiedge_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the count of multiple edges — get_multiedge_count","title":"Get the count of multiple edges — get_multiedge_count","text":"Get count number multiple edges graph. Included count number separate edges share edge definition (.e., pair nodes) across entire graph. , example, 2 edge definitions graph involve 6 separate edge IDs, count 4.","code":""},{"path":"/reference/get_multiedge_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the count of multiple edges — get_multiedge_count","text":"","code":"get_multiedge_count(graph)"},{"path":"/reference/get_multiedge_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the count of multiple edges — get_multiedge_count","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_multiedge_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the count of multiple edges — get_multiedge_count","text":"vector single, numerical value.","code":""},{"path":"/reference/get_multiedge_count.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the count of multiple edges — get_multiedge_count","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 5, label = TRUE) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 4, 4, 3, 5, 1, 3, 4), to = c(4, 1, 1, 2, 2, 2, 2, 1)) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get the total number of multiple # edges (those edges that share an # edge definition) in the graph graph %>% get_multiedge_count() #> [1] 3"},{"path":"/reference/get_nbrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get all neighbors of one or more nodes — get_nbrs","title":"Get all neighbors of one or more nodes — get_nbrs","text":"one nodes, get set neighboring nodes.","code":""},{"path":"/reference/get_nbrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get all neighbors of one or more nodes — get_nbrs","text":"","code":"get_nbrs(graph, nodes)"},{"path":"/reference/get_nbrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get all neighbors of one or more nodes — get_nbrs","text":"graph graph object class dgr_graph. nodes vector node ID values.","code":""},{"path":"/reference/get_nbrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get all neighbors of one or more nodes — get_nbrs","text":"vector node ID values.","code":""},{"path":"/reference/get_nbrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get all neighbors of one or more nodes — get_nbrs","text":"","code":"# Create a simple, directed graph with 5 # nodes and 4 edges graph <- create_graph() %>% add_path(n = 5) # Find all neighbor nodes for node `2` graph %>% get_nbrs(nodes = 2) #> [1] 1 3 # Find all neighbor nodes for nodes `1` # and `5` graph %>% get_nbrs(nodes = c(1, 5)) #> [1] 2 4 # Color node `3` with purple, get its # neighbors and color those nodes green graph <- graph %>% select_nodes_by_id(nodes = 3) %>% set_node_attrs_ws( node_attr = color, value = \"purple\") %>% clear_selection() %>% select_nodes_by_id( nodes = get_nbrs( graph = ., nodes = 3)) %>% set_node_attrs_ws( node_attr = color, value = \"green\")"},{"path":"/reference/get_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node attribute values — get_node_attrs","title":"Get node attribute values — get_node_attrs","text":"graph object class dgr_graph, get node attribute values one nodes.","code":""},{"path":"/reference/get_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node attribute values — get_node_attrs","text":"","code":"get_node_attrs(graph, node_attr, nodes = NULL)"},{"path":"/reference/get_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node attribute values — get_node_attrs","text":"graph graph object class dgr_graph. node_attr name attribute get values. nodes optional vector node IDs filtering list nodes present graph node data frame.","code":""},{"path":"/reference/get_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node attribute values — get_node_attrs","text":"named vector node attribute values attribute given node_attr node ID.","code":""},{"path":"/reference/get_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node attribute values — get_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_node_attrs( node_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # Get all of the values from # the `value` node attribute # as a named vector graph %>% get_node_attrs( node_attr = value) #> 1 2 3 4 #> 2.5 8.2 4.2 2.4 # To only return node attribute # values for specified nodes, # use the `nodes` argument graph %>% get_node_attrs( node_attr = value, nodes = c(1, 3)) #> 1 3 #> 2.5 4.2"},{"path":"/reference/get_node_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node attribute values from a selection of nodes — get_node_attrs_ws","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"graph object class dgr_graph, get node attribute values nodes currently active selection. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/get_node_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"","code":"get_node_attrs_ws(graph, node_attr)"},{"path":"/reference/get_node_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"graph graph object class dgr_graph. node_attr name attribute get values.","code":""},{"path":"/reference/get_node_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"named vector node attribute values attribute given node_attr node ID.","code":""},{"path":"/reference/get_node_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_node_attrs( node_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # Select nodes with ID values # `1` and `3` graph <- graph %>% select_nodes_by_id( nodes = c(1, 3)) # Get the node attribute values # for the `value` attribute, limited # to the current node selection graph %>% get_node_attrs_ws( node_attr = value) #> 1 3 #> 2.5 4.2"},{"path":"/reference/get_node_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a node data frame from a graph — get_node_df","title":"Get a node data frame from a graph — get_node_df","text":"graph, obtain node data frame current node attributes.","code":""},{"path":"/reference/get_node_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a node data frame from a graph — get_node_df","text":"","code":"get_node_df(graph)"},{"path":"/reference/get_node_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a node data frame from a graph — get_node_df","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_node_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a node data frame from a graph — get_node_df","text":"node data frame.","code":""},{"path":"/reference/get_node_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a node data frame from a graph — get_node_df","text":"","code":"# Create a graph graph <- create_graph() %>% add_n_nodes( n = 1, type = \"a\") %>% select_last_nodes_created() %>% add_n_nodes_ws( n = 5, direction = \"from\", type = \"b\") %>% select_nodes_by_id( nodes = 1) %>% set_node_attrs_ws( node_attr = value, value = 25.3) %>% clear_selection() %>% select_nodes_by_id( nodes = 2:4) %>% set_node_attrs_ws( node_attr = color, value = \"grey70\") %>% invert_selection() %>% set_node_attrs_ws( node_attr = color, value = \"grey80\") %>% clear_selection() # Get the graph's internal node # data frame (ndf) graph %>% get_node_df() #> id type label value color #> 1 1 a 25.3 grey80 #> 2 2 b NA grey70 #> 3 3 b NA grey70 #> 4 4 b NA grey70 #> 5 5 b NA grey80 #> 6 6 b NA grey80"},{"path":"/reference/get_node_df_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"graph object class dgr_graph, get graph's internal node data frame filtered node ID values currently active selection. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/get_node_df_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"","code":"get_node_df_ws(graph)"},{"path":"/reference/get_node_df_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_node_df_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"node data frame.","code":""},{"path":"/reference/get_node_df_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_node_attrs( node_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # Select nodes with ID values # `1` and `3` graph <- graph %>% select_nodes_by_id( nodes = c(1, 3)) # Get the node data frame that's # limited to the rows that correspond # to the node selection graph %>% get_node_df_ws() #> id type label value #> 1 1 1 2.5 #> 2 3 3 4.2"},{"path":"/reference/get_node_ids.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a vector of node ID values — get_node_ids","title":"Get a vector of node ID values — get_node_ids","text":"Obtain vector node ID values graph object. optional filter node attribute can limit set node ID values returned.","code":""},{"path":"/reference/get_node_ids.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a vector of node ID values — get_node_ids","text":"","code":"get_node_ids(graph, conditions = NULL)"},{"path":"/reference/get_node_ids.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a vector of node ID values — get_node_ids","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval nodes.","code":""},{"path":"/reference/get_node_ids.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a vector of node ID values — get_node_ids","text":"vector node ID values.","code":""},{"path":"/reference/get_node_ids.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a vector of node ID values — get_node_ids","text":"","code":"# Create a node data # frame (ndf) ndf <- create_node_df( n = 4, type = \"letter\", color = c( \"red\", \"green\", \"blue\", \"blue\"), value = c( 3.5, 2.6, 9.4, 2.7)) # Create a graph using # the ndf graph <- create_graph( nodes_df = ndf) # Get a vector of all nodes in a graph graph %>% get_node_ids() #> [1] 1 2 3 4 # Get a vector of node ID values using a # numeric comparison (i.e., all nodes with # `value` attribute greater than 3) graph %>% get_node_ids( conditions = value > 3) #> [1] 1 3 # Get a vector of node ID values using # a match pattern (i.e., all nodes with # `color` attribute of `green`) graph %>% get_node_ids( conditions = color == \"green\") #> [1] 2 # Use multiple conditions to return nodes # with the desired attribute values graph %>% get_node_ids( conditions = color == \"blue\" & value > 5) #> [1] 3"},{"path":"/reference/get_node_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get detailed information on nodes — get_node_info","title":"Get detailed information on nodes — get_node_info","text":"Obtain data frame detailed information nodes interrelationships within graph.","code":""},{"path":"/reference/get_node_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get detailed information on nodes — get_node_info","text":"","code":"get_node_info(graph)"},{"path":"/reference/get_node_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get detailed information on nodes — get_node_info","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_node_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get detailed information on nodes — get_node_info","text":"data frame containing information specific node within graph.","code":""},{"path":"/reference/get_node_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get detailed information on nodes — get_node_info","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) # Get information on the graph's nodes graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 1 4 3 1 0 #> 2 2 2 4 1 3 0 #> 3 3 3 6 2 4 0 #> 4 4 4 3 2 1 0 #> 5 5 5 3 2 1 0"},{"path":"/reference/get_non_nbrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get non-neighbors of a node in a graph — get_non_nbrs","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"Get set nodes neighboring single graph node.","code":""},{"path":"/reference/get_non_nbrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"","code":"get_non_nbrs(graph, node)"},{"path":"/reference/get_non_nbrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"graph graph object class dgr_graph. node single-length vector containing node ID value.","code":""},{"path":"/reference/get_non_nbrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"vector node ID values.","code":""},{"path":"/reference/get_non_nbrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"","code":"# Create a simple, directed graph with 5 # nodes and 4 edges graph <- create_graph() %>% add_path(n = 5) # Find all non-neighbors of node `2` graph %>% get_non_nbrs(node = 2) #> [1] 4 5"},{"path":"/reference/get_pagerank.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the PageRank values for all nodes — get_pagerank","title":"Get the PageRank values for all nodes — get_pagerank","text":"Get PageRank values nodes graph.","code":""},{"path":"/reference/get_pagerank.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the PageRank values for all nodes — get_pagerank","text":"","code":"get_pagerank(graph, directed = TRUE, damping = 0.85)"},{"path":"/reference/get_pagerank.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the PageRank values for all nodes — get_pagerank","text":"graph graph object class dgr_graph. directed TRUE (default) directed paths considered directed graphs. ignored undirected graphs. damping damping factor. default value set 0.85.","code":""},{"path":"/reference/get_pagerank.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the PageRank values for all nodes — get_pagerank","text":"data frame PageRank values nodes.","code":""},{"path":"/reference/get_pagerank.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the PageRank values for all nodes — get_pagerank","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the PageRank scores # for all nodes in the graph graph %>% get_pagerank() #> id pagerank #> 1 1 0.1302 #> 2 2 0.1037 #> 3 3 0.0450 #> 4 4 0.0450 #> 5 5 0.1501 #> 6 6 0.0578 #> 7 7 0.0871 #> 8 8 0.1780 #> 9 9 0.0744 #> 10 10 0.1287 # Colorize nodes according to their # PageRank scores graph <- graph %>% join_node_attrs( df = get_pagerank(graph = .)) %>% colorize_node_attrs( node_attr_from = pagerank, node_attr_to = fillcolor, palette = \"RdYlGn\")"},{"path":"/reference/get_paths.html","id":null,"dir":"Reference","previous_headings":"","what":"Get paths from a specified node in a directed graph — get_paths","title":"Get paths from a specified node in a directed graph — get_paths","text":"Obtain list possible paths given node within directed graph.","code":""},{"path":"/reference/get_paths.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get paths from a specified node in a directed graph — get_paths","text":"","code":"get_paths( graph, from = NULL, to = NULL, shortest_path = FALSE, longest_path = FALSE, distance = NULL )"},{"path":"/reference/get_paths.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get paths from a specified node in a directed graph — get_paths","text":"graph graph object class dgr_graph. node paths determined. node paths determined. shortest_path option return paths shortest set determined paths. longest_path option return paths longest set determined paths. distance vector integer values specify valid paths return filtering distance.","code":""},{"path":"/reference/get_paths.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get paths from a specified node in a directed graph — get_paths","text":"list paths, sorted ascending traversal length, comprising vectors node IDs sequence traversal graph.","code":""},{"path":"/reference/get_paths.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get paths from a specified node in a directed graph — get_paths","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_n_nodes(n = 8) %>% add_edge(from = 1, to = 2) %>% add_edge(from = 1, to = 3) %>% add_edge(from = 3, to = 4) %>% add_edge(from = 3, to = 5) %>% add_edge(from = 4, to = 6) %>% add_edge(from = 2, to = 7) %>% add_edge(from = 7, to = 5) %>% add_edge(from = 4, to = 8) # Get a list of all paths outward from node `1` graph %>% get_paths(from = 1) #> [[1]] #> [1] 1 3 5 #> #> [[2]] #> [1] 1 2 7 5 #> #> [[3]] #> [1] 1 3 4 6 #> #> [[4]] #> [1] 1 3 4 8 #> # Get a list of all paths leading to node `6` graph %>% get_paths(to = 6) #> [[1]] #> [1] 1 3 4 6 #> # Get a list of all paths from `1` to `5` graph %>% get_paths( from = 1, to = 5) #> [[1]] #> [1] 1 3 5 #> #> [[2]] #> [1] 1 2 7 5 #> # Get a list of all paths from `1` up to a distance # of 2 node traversals graph %>% get_paths( from = 1, distance = 2) #> [[1]] #> [1] 1 3 5 #> #> [[2]] #> [1] 1 2 7 #> #> [[3]] #> [1] 1 3 4 #> # Get a list of the shortest paths from `1` to `5` get_paths( graph, from = 1, to = 5, shortest_path = TRUE) #> [[1]] #> [1] 1 3 5 #> # Get a list of the longest paths from `1` to `5` get_paths( graph, from = 1, to = 5, longest_path = TRUE) #> [[1]] #> [1] 1 2 7 5 #>"},{"path":"/reference/get_periphery.html","id":null,"dir":"Reference","previous_headings":"","what":"Get nodes that form the graph periphery — get_periphery","title":"Get nodes that form the graph periphery — get_periphery","text":"Get nodes part graph periphery (.e., maximum eccentricity graph).","code":""},{"path":"/reference/get_periphery.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get nodes that form the graph periphery — get_periphery","text":"","code":"get_periphery(graph)"},{"path":"/reference/get_periphery.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get nodes that form the graph periphery — get_periphery","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_periphery.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get nodes that form the graph periphery — get_periphery","text":"vector node IDs.","code":""},{"path":"/reference/get_periphery.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get nodes that form the graph periphery — get_periphery","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function and # get the nodes in the graph periphery create_graph() %>% add_gnm_graph( n = 28, m = 35, set_seed = 23) %>% get_periphery() #> [1] 6 9 25 28"},{"path":"/reference/get_predecessors.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node IDs for predecessor nodes to the specified node — get_predecessors","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"Provides vector node IDs nodes connection given node.","code":""},{"path":"/reference/get_predecessors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"","code":"get_predecessors(graph, node)"},{"path":"/reference/get_predecessors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"graph graph object class dgr_graph. node node ID selected node.","code":""},{"path":"/reference/get_predecessors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"vector node ID values.","code":""},{"path":"/reference/get_predecessors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a node data frame (ndf) ndf <- create_node_df(n = 26) # Create an edge data # frame (edf) edf <- create_edge_df( from = sample( 1:26, replace = TRUE), to = sample( 1:26, replace = TRUE)) # From the ndf and edf, # create a graph object graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get predecessors for node # `23` in the graph graph %>% get_predecessors( node = 23) #> [1] 6 # If there are no predecessors, # `NA` is returned graph %>% get_predecessors( node = 26) #> [1] NA"},{"path":"/reference/get_radiality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get radiality centrality scores — get_radiality","title":"Get radiality centrality scores — get_radiality","text":"Get radiality centrality nodes graph. scores describe ease nodes can reach nodes.","code":""},{"path":"/reference/get_radiality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get radiality centrality scores — get_radiality","text":"","code":"get_radiality(graph, direction = \"all\")"},{"path":"/reference/get_radiality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get radiality centrality scores — get_radiality","text":"graph graph object class dgr_graph. direction Using (default), search ignore edge direction traversing graph. , measurements paths node whereas , measurements paths node.","code":""},{"path":"/reference/get_radiality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get radiality centrality scores — get_radiality","text":"data frame radiality centrality scores nodes.","code":""},{"path":"/reference/get_radiality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get radiality centrality scores — get_radiality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the radiality scores for nodes in the graph graph %>% get_radiality() #> id radiality #> 1 1 2.3333 #> 2 2 3.0000 #> 3 3 2.6667 #> 4 4 2.8889 #> 5 5 2.5556 #> 6 6 2.4444 #> 7 7 2.6667 #> 8 8 2.7778 #> 9 9 2.1111 #> 10 10 2.3333 # Add the radiality values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_radiality(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label radiality #> 1 1 1 2.3333 #> 2 2 2 3.0000 #> 3 3 3 2.6667 #> 4 4 4 2.8889 #> 5 5 5 2.5556 #> 6 6 6 2.4444 #> 7 7 7 2.6667 #> 8 8 8 2.7778 #> 9 9 9 2.1111 #> 10 10 10 2.3333"},{"path":"/reference/get_reciprocity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph reciprocity — get_reciprocity","title":"Get the graph reciprocity — get_reciprocity","text":"Get reciprocity directed graph. reciprocity graph fraction reciprocal edges (e.g., 1 -> 2 2 -> 1) edges available graph. Note undirected graph, edges reciprocal. function consider loop edges (e.g., 1 -> 1).","code":""},{"path":"/reference/get_reciprocity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph reciprocity — get_reciprocity","text":"","code":"get_reciprocity(graph)"},{"path":"/reference/get_reciprocity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph reciprocity — get_reciprocity","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_reciprocity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph reciprocity — get_reciprocity","text":"single, numerical value ratio value reciprocal edges graph edges.","code":""},{"path":"/reference/get_reciprocity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph reciprocity — get_reciprocity","text":"","code":"# Define a graph where 2 edge definitions # have pairs of reciprocal edges graph <- create_graph() %>% add_cycle(n = 3) %>% add_node( from = 1, to = 1) %>% add_node( from = 1, to = 1) # Get the graph reciprocity, which will # be calculated as the ratio 4/7 (where # 4 is the number reciprocating edges # and 7 is the total number of edges # in the graph) graph %>% get_reciprocity() #> [1] 0.5714286 # For an undirected graph, all edges # are reciprocal, so the ratio will # always be 1 graph %>% set_graph_undirected() %>% get_reciprocity() #> [1] 1 # For a graph with no edges, the graph # reciprocity cannot be determined (and # the same NA result is obtained from an # empty graph) create_graph() %>% add_n_nodes(n = 5) %>% get_reciprocity() #> [1] NA"},{"path":"/reference/get_s_connected_cmpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Get nodes within strongly connected components — get_s_connected_cmpts","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"Determine nodes graph belong different strongly connected components.","code":""},{"path":"/reference/get_s_connected_cmpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"","code":"get_s_connected_cmpts(graph)"},{"path":"/reference/get_s_connected_cmpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_s_connected_cmpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"data frame nodes membership different strongly connected components.","code":""},{"path":"/reference/get_s_connected_cmpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"","code":"suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a graph with a random # connection between 2 different # node cycles graph <- create_graph() %>% add_cycle( n = 3, type = \"cycle_1\") %>% add_cycle( n = 4, type = \"cycle_2\") %>% add_edge( from = get_node_ids( graph = ., conditions = type == \"cycle_1\") %>% sample(size = 1), to = get_node_ids( graph = ., conditions = type == \"cycle_2\") %>% sample(size = 1)) # Get the strongly connected # components as a data frame of # nodes and their groupings graph %>% get_s_connected_cmpts() #> id sc_component #> 1 1 1 #> 2 2 1 #> 3 3 1 #> 4 4 2 #> 5 5 2 #> 6 6 2 #> 7 7 2"},{"path":"/reference/get_selection.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the current selection available in a graph object — get_selection","title":"Get the current selection available in a graph object — get_selection","text":"Get current selection node IDs edge IDs graph object class dgr_graph.","code":""},{"path":"/reference/get_selection.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the current selection available in a graph object — get_selection","text":"","code":"get_selection(graph)"},{"path":"/reference/get_selection.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the current selection available in a graph object — get_selection","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_selection.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the current selection available in a graph object — get_selection","text":"vector current selection node edge ID values.","code":""},{"path":"/reference/get_selection.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the current selection available in a graph object — get_selection","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_path(n = 6) # Select node `4`, then select # all nodes a distance of 1 away # from node `4`, and finally # return the selection of nodes as # a vector object graph %>% select_nodes(nodes = 4) %>% select_nodes_in_neighborhood( node = 4, distance = 1) %>% get_selection() #> [1] 3 4 5 # Select edges associated with # node `4` and return the # selection of edges graph %>% select_edges_by_node_id( nodes = 4) %>% get_selection() #> [1] 3 4"},{"path":"/reference/get_similar_nbrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"graph single node serving starting point, get nodes potential neighborhood nodes (adjacent starting node) common similar (within threshold values) node attribute starting node.","code":""},{"path":"/reference/get_similar_nbrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"","code":"get_similar_nbrs(graph, node, node_attr, tol_abs = NULL, tol_pct = NULL)"},{"path":"/reference/get_similar_nbrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"graph graph object class dgr_graph. node single-length vector containing node ID value. node_attr name node attribute use compare adjacent nodes. tol_abs values contained node attribute node_attr numeric, one can optionally supply numeric vector length 2 provides lower upper numeric bound criteria neighboring node similarity starting node. tol_pct values contained node attribute node_attr numeric, one can optionally supply numeric vector length 2 specifies lower upper bounds negative positive percentage changes value starting node. bounds serve criteria neighboring node similarity starting node.","code":""},{"path":"/reference/get_similar_nbrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"vector node ID values.","code":""},{"path":"/reference/get_similar_nbrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"","code":"# Getting similar neighbors can # be done through numerical comparisons; # start by creating a random, directed # graph with 18 nodes and 22 edges # using the `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 18, m = 25, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(0)) # Starting with node `10`, we # can test whether any nodes # adjacent and beyond are # numerically equivalent in `value` graph %>% get_similar_nbrs( node = 10, node_attr = value) #> [1] 2 14 # We can also set a tolerance # for ascribing similarly by using # either the `tol_abs` or `tol_pct` # arguments (the first applies absolute # lower and upper bounds from the # value in the starting node and the # latter uses a percentage difference # to do the same); try setting `tol_abs` # with a fairly large range to # determine if several nodes can be # selected graph %>% get_similar_nbrs( node = 10, node_attr = value, tol_abs = c(1, 1)) #> [1] 1 2 9 14 # That resulted in a fairly large # set of 4 neigboring nodes; for # sake of example, setting the range # to be very large will effectively # return all nodes in the graph # except for the starting node graph %>% get_similar_nbrs( node = 10, node_attr = value, tol_abs = c(10, 10)) %>% length() #> [1] 17"},{"path":"/reference/get_successors.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node IDs for successor nodes to the specified node — get_successors","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"Provides vector node IDs nodes connection given node.","code":""},{"path":"/reference/get_successors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"","code":"get_successors(graph, node)"},{"path":"/reference/get_successors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"graph graph object class dgr_graph. node node ID selected node.","code":""},{"path":"/reference/get_successors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"vector node ID values.","code":""},{"path":"/reference/get_successors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a node data frame (ndf) ndf <- create_node_df(n = 26) # Create an edge data # frame (edf) edf <- create_edge_df( from = sample( 1:26, replace = TRUE), to = sample( 1:26, replace = TRUE)) # From the ndf and edf, # create a graph object graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get sucessors for node # `4` in the graph graph %>% get_successors( node = 4) #> [1] 3 8 # If there are no successors, # NA is returned graph %>% get_successors( node = 1) #> [1] NA"},{"path":"/reference/get_w_connected_cmpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Get all nodes associated with connected components — get_w_connected_cmpts","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"Determine nodes graph belong different weakly connected components (.e., distinct sets nodes traversable paths node set).","code":""},{"path":"/reference/get_w_connected_cmpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"","code":"get_w_connected_cmpts(graph)"},{"path":"/reference/get_w_connected_cmpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_w_connected_cmpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"data frame nodes membership different weakly connected components.","code":""},{"path":"/reference/get_w_connected_cmpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"","code":"# Create a graph with 2 cycles graph <- create_graph() %>% add_cycle(n = 4) %>% add_cycle(n = 3) # Check if the graph is connected graph %>% is_graph_connected() #> [1] FALSE # Get the graph's weakly-connected # components graph %>% get_w_connected_cmpts() #> id wc_component #> 1 1 1 #> 2 2 1 #> 3 3 1 #> 4 4 1 #> 5 5 2 #> 6 6 2 #> 7 7 2"},{"path":"/reference/grViz.html","id":null,"dir":"Reference","previous_headings":"","what":"R + viz.js — grViz","title":"R + viz.js — grViz","text":"Make diagrams R using viz.js infrastructure provided htmlwidgets.","code":""},{"path":"/reference/grViz.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"R + viz.js — grViz","text":"","code":"grViz( diagram = \"\", engine = \"dot\", allow_subst = TRUE, options = NULL, width = NULL, height = NULL, envir = parent.frame() )"},{"path":"/reference/grViz.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"R + viz.js — grViz","text":"diagram Spec diagram either text, filename string, file connection. engine String Graphviz layout engine; can dot (default), neato, circo, twopi. allow_subst boolean enables/disables substitution functionality. options Parameters supplied htmlwidgets framework. width optional parameter specifying width resulting graphic pixels. height optional parameter specifying height resulting graphic pixels. envir environment substitution functionality takes place.","code":""},{"path":"/reference/grViz.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"R + viz.js — grViz","text":"object class htmlwidget intelligently print HTML variety contexts including R console, within R Markdown documents, within Shiny output bindings.","code":""},{"path":"/reference/grVizOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Widget output function for use in Shiny — grVizOutput","title":"Widget output function for use in Shiny — grVizOutput","text":"Widget output function use Shiny","code":""},{"path":"/reference/grVizOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Widget output function for use in Shiny — grVizOutput","text":"","code":"grVizOutput(outputId, width = \"100%\", height = \"400px\")"},{"path":"/reference/grVizOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Widget output function for use in Shiny — grVizOutput","text":"outputId Output variable read . width valid CSS unit width number, coerced string px appended. height valid CSS unit height number, coerced string px appended.","code":""},{"path":"/reference/import_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Import a graph from various graph formats — import_graph","title":"Import a graph from various graph formats — import_graph","text":"Import variety graphs different graph formats create graph object.","code":""},{"path":"/reference/import_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import a graph from various graph formats — import_graph","text":"","code":"import_graph( graph_file, file_type = NULL, edges_extra_attr_names = NULL, edges_extra_attr_coltypes = NULL, graph_name = NULL, attr_theme = \"default\", write_backups = FALSE, display_msgs = FALSE )"},{"path":"/reference/import_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import a graph from various graph formats — import_graph","text":"graph_file connection graph file. provided path file, read file disk. Files starting http://, https://, ftp://, ftps:// automatically downloaded. file_type type file imported. Options : gml (GML), sif (SIF), edges (.edges file), mtx (MatrixMarket format). supplied, type graph file inferred file extension. edges_extra_attr_names edges files, vector attribute names beyond data columns can provided order appear input data file. edges_extra_attr_coltypes edges files, string column types attribute columns provided edges_extra_attr_names. string representation character represents extra columns data mappings : c -> character, -> integer, n -> number, d -> double, l -> logical, D -> date, T -> date time, t -> time, ? -> guess, _/-, skips column. graph_name optional string labeling graph object. attr_theme theme (.e., collection graph, node, edge global graph attributes) use graph. default theme called default; hierarchical layout themes called lr, tb, rl, bt (operate left--right, top--bottom, right--left, bottom--top); , larger graphs, fdp theme provides force directed layout. set NULL global graph attributes applied graph upon creation. write_backups option write incremental backups changing graph states disk. TRUE, subdirectory within working directory created used store RDS files. default value FALSE one opt use functionality. display_msgs option display messages primarily concerned changes graph selections. default, FALSE.","code":""},{"path":"/reference/import_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Import a graph from various graph formats — import_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/import_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Import a graph from various graph formats — import_graph","text":"","code":"if (FALSE) { # Import a GML graph file gml_graph <- import_graph( system.file( \"extdata/karate.gml\", package = \"DiagrammeR\")) # Get a count of the graph's nodes gml_graph %>% count_nodes() # Get a count of the graph's edges gml_graph %>% count_edges() }"},{"path":"/reference/invert_selection.html","id":null,"dir":"Reference","previous_headings":"","what":"Invert selection of nodes or edges in a graph — invert_selection","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"Modify selection nodes edges within graph object nodes edges previously selected now selected vice versa.","code":""},{"path":"/reference/invert_selection.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"","code":"invert_selection(graph)"},{"path":"/reference/invert_selection.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/invert_selection.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"graph object class dgr_graph.","code":""},{"path":"/reference/invert_selection.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"standard\") # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\") # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Select nodes with ID # values `1` and `3` graph <- graph %>% select_nodes( nodes = c(1, 3)) # Verify that a node # selection has been made graph %>% get_selection() #> [1] 1 3 # Invert the selection graph <- graph %>% invert_selection() # Verify that the node # selection has been changed graph %>% get_selection() #> [1] 2 4"},{"path":"/reference/is_edge_loop.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the edge a loop edge? — is_edge_loop","title":"Is the edge a loop edge? — is_edge_loop","text":"Determines whether edge definition loop edge.","code":""},{"path":"/reference/is_edge_loop.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the edge a loop edge? — is_edge_loop","text":"","code":"is_edge_loop(graph, edge)"},{"path":"/reference/is_edge_loop.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the edge a loop edge? — is_edge_loop","text":"graph graph object class dgr_graph. edge numeric edge ID value.","code":""},{"path":"/reference/is_edge_loop.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the edge a loop edge? — is_edge_loop","text":"logical value.","code":""},{"path":"/reference/is_edge_loop.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the edge a loop edge? — is_edge_loop","text":"","code":"# Create a graph that has multiple # loop edges graph <- create_graph() %>% add_path(n = 4) %>% add_edge( from = 1, to = 1) %>% add_edge( from = 3, to = 3) # Get the graph's internal # edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 1 1 #> 5 5 3 3 # Determine if edge `4` is # a loop edge graph %>% is_edge_loop(edge = 4) #> [1] TRUE # Determine if edge `2` is # a loop edge graph %>% is_edge_loop(edge = 2) #> [1] FALSE"},{"path":"/reference/is_edge_multiple.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the edge a multiple edge? — is_edge_multiple","title":"Is the edge a multiple edge? — is_edge_multiple","text":"Determines whether edge definition multiple edge IDs associated node pair.","code":""},{"path":"/reference/is_edge_multiple.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the edge a multiple edge? — is_edge_multiple","text":"","code":"is_edge_multiple(graph, edge)"},{"path":"/reference/is_edge_multiple.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the edge a multiple edge? — is_edge_multiple","text":"graph graph object class dgr_graph. edge numeric edge ID value.","code":""},{"path":"/reference/is_edge_multiple.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the edge a multiple edge? — is_edge_multiple","text":"logical value.","code":""},{"path":"/reference/is_edge_multiple.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the edge a multiple edge? — is_edge_multiple","text":"","code":"# Create a graph that has multiple # edges across some node pairs graph <- create_graph() %>% add_path(n = 4) %>% add_edge( from = 1, to = 2) %>% add_edge( from = 3, to = 4) # Get the graph's internal # edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 1 2 #> 5 5 3 4 # Determine if edge `1` is # a multiple edge graph %>% is_edge_multiple(edge = 1) #> [1] TRUE # Determine if edge `2` is # a multiple edge graph %>% is_edge_multiple(edge = 2) #> [1] FALSE"},{"path":"/reference/is_edge_mutual.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the edge mutual with another edge? — is_edge_mutual","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"Determines whether edge definition mutual analogue node pair.","code":""},{"path":"/reference/is_edge_mutual.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"","code":"is_edge_mutual(graph, edge)"},{"path":"/reference/is_edge_mutual.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"graph graph object class dgr_graph. edge numeric edge ID value.","code":""},{"path":"/reference/is_edge_mutual.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"logical value.","code":""},{"path":"/reference/is_edge_mutual.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"","code":"# Create a graph that has mutual # edges across some node pairs graph <- create_graph() %>% add_path(n = 4) %>% add_edge( from = 4, to = 3) %>% add_edge( from = 2, to = 1) # Get the graph's internal # edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 4 3 #> 5 5 2 1 # Determine if edge `1` has # a mutual edge graph %>% is_edge_mutual(edge = 1) #> [1] TRUE # Determine if edge `2` has # a mutual edge graph %>% is_edge_mutual(edge = 2) #> [1] FALSE"},{"path":"/reference/is_edge_present.html","id":null,"dir":"Reference","previous_headings":"","what":"Determine whether a specified edge is present — is_edge_present","title":"Determine whether a specified edge is present — is_edge_present","text":"graph object class dgr_graph, determine whether edge (defined pair node IDs node label values) present.","code":""},{"path":"/reference/is_edge_present.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Determine whether a specified edge is present — is_edge_present","text":"","code":"is_edge_present(graph, edge = NULL, from = NULL, to = NULL)"},{"path":"/reference/is_edge_present.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Determine whether a specified edge is present — is_edge_present","text":"graph graph object class dgr_graph. edge edge ID value test presence graph. single, numeric value provided values needn't supplied. node ID edge outgoing, , label associated node. undirected graph, value can interchangeable . node ID edge incoming, , label associated node. undirected graph, value can interchangeable .","code":""},{"path":"/reference/is_edge_present.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Determine whether a specified edge is present — is_edge_present","text":"logical value.","code":""},{"path":"/reference/is_edge_present.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Determine whether a specified edge is present — is_edge_present","text":"","code":"# Create a simple graph with # a path of four nodes graph <- create_graph() %>% add_path( n = 4, type = \"path\", label = c(\"one\", \"two\", \"three\", \"four\")) # Find out if edge ID `3` # is present in the graph graph %>% is_edge_present(edge = 3) #> [1] TRUE # Determine if there are any edges # with the definition `1` -> `2` graph %>% is_edge_present( from = 1, to = 2) #> [1] TRUE # Determine if there are any edges # with the definition `4` -> `5` graph %>% is_edge_present( from = 4, to = 5) #> [1] FALSE # Determine whether an edge, # defined by its labels as # `two` -> `three`, exists in # the graph graph %>% is_edge_present( from = \"two\", to = \"three\") #> [1] TRUE # Set the graph as undirected # and determine whether an # edge between nodes with labels # `three` and `two` exists graph %>% set_graph_undirected() %>% is_edge_present( from = \"three\", to = \"two\") #> [1] TRUE"},{"path":"/reference/is_graph_connected.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a connected graph? — is_graph_connected","title":"Is the graph a connected graph? — is_graph_connected","text":"Determines whether graph connected graph.","code":""},{"path":"/reference/is_graph_connected.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a connected graph? — is_graph_connected","text":"","code":"is_graph_connected(graph)"},{"path":"/reference/is_graph_connected.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a connected graph? — is_graph_connected","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_connected.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a connected graph? — is_graph_connected","text":"logical value.","code":""},{"path":"/reference/is_graph_connected.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a connected graph? — is_graph_connected","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function; this # graph is not connected create_graph() %>% add_gnm_graph( n = 15, m = 10, set_seed = 23) %>% is_graph_connected() #> [1] FALSE # Create another random graph; # this graph is connected create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) %>% is_graph_connected() #> [1] TRUE"},{"path":"/reference/is_graph_dag.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a directed acyclic graph? — is_graph_dag","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"Provides logical value whether graph directed acyclic graph (DAG). conditions graph DAG directed graph contain cycles.","code":""},{"path":"/reference/is_graph_dag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"","code":"is_graph_dag(graph)"},{"path":"/reference/is_graph_dag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_dag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"logical value.","code":""},{"path":"/reference/is_graph_dag.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"","code":"# Create a directed graph containing # only a balanced tree graph_tree <- create_graph() %>% add_balanced_tree( k = 2, h = 3) # Determine whether this graph # is a DAG graph_tree %>% is_graph_dag() #> [1] TRUE # Create a directed graph containing # a single cycle graph_cycle <- create_graph() %>% add_cycle(n = 5) # Determine whether this graph # is a DAG graph_cycle %>% is_graph_dag() #> [1] FALSE # Create an undirected graph # containing a balanced tree graph_tree_undirected <- create_graph( directed = FALSE) %>% add_balanced_tree( k = 2, h = 2) # Determine whether this graph # is a DAG graph_tree_undirected %>% is_graph_dag() #> [1] FALSE"},{"path":"/reference/is_graph_directed.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a directed graph? — is_graph_directed","title":"Is the graph a directed graph? — is_graph_directed","text":"Determines whether graph set directed returns logical value effect.","code":""},{"path":"/reference/is_graph_directed.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a directed graph? — is_graph_directed","text":"","code":"is_graph_directed(graph)"},{"path":"/reference/is_graph_directed.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a directed graph? — is_graph_directed","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_directed.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a directed graph? — is_graph_directed","text":"logical value.","code":""},{"path":"/reference/is_graph_directed.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a directed graph? — is_graph_directed","text":"","code":"# Create an empty graph; by default, # new graphs made by `create_graph()` # are directed graph <- create_graph() # Determine whether the graph # is directed graph %>% is_graph_directed() #> [1] TRUE # Use the `set_graph_undirected()` # function and check again whether # the graph is directed graph %>% set_graph_undirected() %>% is_graph_directed() #> [1] FALSE"},{"path":"/reference/is_graph_empty.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph empty? — is_graph_empty","title":"Is the graph empty? — is_graph_empty","text":"Provides logical value whether graph empty (.e., contains nodes).","code":""},{"path":"/reference/is_graph_empty.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph empty? — is_graph_empty","text":"","code":"is_graph_empty(graph)"},{"path":"/reference/is_graph_empty.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph empty? — is_graph_empty","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_empty.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph empty? — is_graph_empty","text":"logical value.","code":""},{"path":"/reference/is_graph_empty.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph empty? — is_graph_empty","text":"","code":"# Create an empty graph graph <- create_graph() # Determine whether the graph is empty graph %>% is_graph_empty() #> [1] TRUE # Create a non-empty graph graph <- create_graph() %>% add_n_nodes(n = 3) # Determine whether this graph is empty graph %>% is_graph_empty() #> [1] FALSE"},{"path":"/reference/is_graph_simple.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a simple graph? — is_graph_simple","title":"Is the graph a simple graph? — is_graph_simple","text":"Determine whether graph simple graph. simple graph one contain loops multiple edges.","code":""},{"path":"/reference/is_graph_simple.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a simple graph? — is_graph_simple","text":"","code":"is_graph_simple(graph)"},{"path":"/reference/is_graph_simple.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a simple graph? — is_graph_simple","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_simple.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a simple graph? — is_graph_simple","text":"logical value.","code":""},{"path":"/reference/is_graph_simple.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a simple graph? — is_graph_simple","text":"","code":"# Create a graph with 2 cycles graph <- create_graph() %>% add_cycle(n = 4) %>% add_cycle(n = 3) # Check if the graph is simple graph %>% is_graph_simple() #> [1] TRUE"},{"path":"/reference/is_graph_undirected.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph an undirected graph? — is_graph_undirected","title":"Is the graph an undirected graph? — is_graph_undirected","text":"Determines whether graph set undirected returns logical value effect.","code":""},{"path":"/reference/is_graph_undirected.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph an undirected graph? — is_graph_undirected","text":"","code":"is_graph_undirected(graph)"},{"path":"/reference/is_graph_undirected.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph an undirected graph? — is_graph_undirected","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_undirected.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph an undirected graph? — is_graph_undirected","text":"logical value.","code":""},{"path":"/reference/is_graph_undirected.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph an undirected graph? — is_graph_undirected","text":"","code":"# Create an empty graph; by # default, new graphs made # by `create_graph()` are # directed graph, so, use # `directed = FALSE` to create # an undirected graph graph <- create_graph( directed = FALSE) # Determine whether the # graph is undirected graph %>% is_graph_undirected() #> [1] TRUE # Use the `set_graph_directed()` # function and check again # as to whether the graph is # undirected graph %>% set_graph_directed() %>% is_graph_undirected() #> [1] FALSE"},{"path":"/reference/is_graph_weighted.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a weighted graph? — is_graph_weighted","title":"Is the graph a weighted graph? — is_graph_weighted","text":"Provides logical value whether graph weighted. graph considered weighted contains edges edge weight attribute numerical values assigned edges.","code":""},{"path":"/reference/is_graph_weighted.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a weighted graph? — is_graph_weighted","text":"","code":"is_graph_weighted(graph)"},{"path":"/reference/is_graph_weighted.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a weighted graph? — is_graph_weighted","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_weighted.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a weighted graph? — is_graph_weighted","text":"logical value.","code":""},{"path":"/reference/is_graph_weighted.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a weighted graph? — is_graph_weighted","text":"","code":"# Create a graph where the edges have # a `weight` attribute graph <- create_graph() %>% add_cycle(n = 5) %>% select_edges() %>% set_edge_attrs_ws( edge_attr = weight, value = c(3, 5, 2, 9, 6)) %>% clear_selection() # Determine whether the graph # is a weighted graph graph %>% is_graph_weighted() #> [1] TRUE # Create graph where the edges do # not have a `weight` attribute graph <- create_graph() %>% add_cycle(n = 5) # Determine whether this graph # is weighted graph %>% is_graph_weighted() #> [1] FALSE"},{"path":"/reference/is_node_present.html","id":null,"dir":"Reference","previous_headings":"","what":"Determine whether a specified node is present — is_node_present","title":"Determine whether a specified node is present — is_node_present","text":"graph object class dgr_graph, determine whether specified node present.","code":""},{"path":"/reference/is_node_present.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Determine whether a specified node is present — is_node_present","text":"","code":"is_node_present(graph, node)"},{"path":"/reference/is_node_present.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Determine whether a specified node is present — is_node_present","text":"graph graph object class dgr_graph. node Either node ID value node label test presence graph.","code":""},{"path":"/reference/is_node_present.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Determine whether a specified node is present — is_node_present","text":"logical value.","code":""},{"path":"/reference/is_node_present.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Determine whether a specified node is present — is_node_present","text":"","code":"# Create a simple graph with # a path of four nodes graph <- create_graph() %>% add_path( n = 4, type = \"path\", label = c( \"one\", \"two\", \"three\", \"four\")) # Determine if there is a node # with ID `1` in the graph graph %>% is_node_present(node = 1) #> [1] TRUE # Determine if there is a node # with ID `5` in the graph graph %>% is_node_present(node = 5) #> [1] FALSE # Determine if there is a node # with label `two` in the graph graph %>% is_node_present(node = \"two\") #> [1] TRUE"},{"path":"/reference/is_property_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a property graph? — is_property_graph","title":"Is the graph a property graph? — is_property_graph","text":"Provides logical value whether graph property graph (.e., nodes assigned type value edges assigned rel value).","code":""},{"path":"/reference/is_property_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a property graph? — is_property_graph","text":"","code":"is_property_graph(graph)"},{"path":"/reference/is_property_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a property graph? — is_property_graph","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_property_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a property graph? — is_property_graph","text":"logical value.","code":""},{"path":"/reference/is_property_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a property graph? — is_property_graph","text":"","code":"# Create a graph with 2 nodes # (with `type` values) and a # single edge (with a `rel`) simple_property_graph <- create_graph() %>% add_node( type = \"a\", label = \"first\") %>% add_node( type = \"b\", label = \"second\") %>% add_edge( from = \"first\", to = \"second\", rel = \"rel_1\") # This is indeed a property graph # but to confirm this, use the # `is_property_graph()` function is_property_graph(simple_property_graph) #> [1] TRUE # If a `type` attribute is # removed, then this graph will # no longer be a property graph simple_property_graph %>% set_node_attrs( node_attr = type, values = NA, nodes = 1) %>% is_property_graph() #> [1] FALSE # An empty graph will return FALSE create_graph() %>% is_property_graph() #> [1] FALSE"},{"path":"/reference/join_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Join new edge attribute values using a data frame — join_edge_attrs","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"Join new edge attribute values left join using data frame. use left join function allows possibility edges graph might removed join.","code":""},{"path":"/reference/join_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"","code":"join_edge_attrs(graph, df, by_graph = NULL, by_df = NULL)"},{"path":"/reference/join_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"graph graph object class dgr_graph. df data frame use joining. by_graph Optional specification column graph's internal edge data frame left join. by_graph by_df provided, natural join occur columns graph's edf df identical names. by_df Optional specification column df left join. by_graph by_df provided, natural join occur columns graph's edf df identical names.","code":""},{"path":"/reference/join_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/join_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes(n = 5) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\") # Create a data frame with node ID values # representing the graph edges (with `from` and `to` # columns), and, a set of numeric values df <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = rnorm(5, 5)) # Join the values in the data frame to the # graph's edges; this works as a left join using # identically-named columns in the graph and the df # (in this case `from` and `to` are common to both) graph <- graph %>% join_edge_attrs( df = df) # Get the graph's internal edf to show that the # join has been made graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 5.996605 #> 2 2 1 3 6.107490 #> 3 3 2 4 4.721914 #> 4 4 2 5 6.019205 #> 5 5 3 5 5.045437"},{"path":"/reference/join_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Join new node attribute values using a data frame — join_node_attrs","title":"Join new node attribute values using a data frame — join_node_attrs","text":"Join new node attribute values left join using data frame. use left join function allows possibility nodes graph might removed join.","code":""},{"path":"/reference/join_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Join new node attribute values using a data frame — join_node_attrs","text":"","code":"join_node_attrs(graph, df, by_graph = NULL, by_df = NULL)"},{"path":"/reference/join_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Join new node attribute values using a data frame — join_node_attrs","text":"graph graph object class dgr_graph. df data frame use joining. by_graph Optional specification column graph's internal node data frame left join. by_graph by_df provided, natural join occur columns graph's ndf df identical names. by_df Optional specification column df left join. by_graph by_df provided, natural join occur columns graph's ndf df identical names.","code":""},{"path":"/reference/join_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Join new node attribute values using a data frame — join_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/join_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Join new node attribute values using a data frame — join_node_attrs","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes(n = 5) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\") # Create a data frame with node ID values and a # set of numeric values df <- data.frame( values = round(rnorm(6, 5), 2), id = 1:6) # Join the values in the data frame to the # graph's nodes; this works as a left join using # identically-named columns in the graph and the df # (in this case the `id` column is common to both) graph <- graph %>% join_node_attrs( df = df) # Get the graph's internal ndf to show that the # join has been made graph %>% get_node_df() #> id type label values #> 1 1 6.00 #> 2 2 6.11 #> 3 3 4.72 #> 4 4 6.02 #> 5 5 5.05 # Get betweenness values for each node and # add them as a node attribute (Note the # common column name `id` in the different # tables results in a natural join) graph <- graph %>% join_node_attrs( df = get_betweenness(.)) # Get the graph's internal ndf to show that # this join has been made graph %>% get_node_df() #> id type label values betweenness #> 1 1 6.00 0.0 #> 2 2 6.11 1.5 #> 3 3 4.72 0.5 #> 4 4 6.02 0.0 #> 5 5 5.05 0.0"},{"path":"/reference/layout_nodes_w_string.html","id":null,"dir":"Reference","previous_headings":"","what":"Layout nodes using a text-based schematic — layout_nodes_w_string","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"Layout one several groups nodes using text-based schematic. option available apply sorting groups.","code":""},{"path":"/reference/layout_nodes_w_string.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"","code":"layout_nodes_w_string( graph, layout, nodes, sort = NULL, width = 8, height = 8, ll = c(0, 0) )"},{"path":"/reference/layout_nodes_w_string.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"graph graph object class dgr_graph. layout layout character string provides schematic layout. consists rectangular collection - characters (node placement), numbers 1 9 (representing different groupings nodes, described nodes argument). nodes named vector form: c(\"1\" = \"[node_attr]:[value]\", ...). LHS corresponds numbers used layout schematic. RHS provides shorthand node attribute value grouping together nodes (separated colon). instance, \"type:\" RHS (\"1\" LHS) target nodes type attribute equal positioning graph described 1s layout. sort optional sorting method apply collection nodes assigning positional information. Like nodes, named vector form: c(\"1\" = \"[node_attr]:asc|desc\", ...). node_attr case different used nodes. Ideally, node attribute unique values. Choose either asc desc right colon ascending descending sorts. width width layout diagram. height height layout diagram. ll vector describing lower-left coordinates layout","code":""},{"path":"/reference/layout_nodes_w_string.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/layout_nodes_w_string.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"","code":"# Create a graph with unique labels and # several node `type` groupings graph <- create_graph() %>% add_node(type = \"a\", label = \"a\") %>% add_node(type = \"a\", label = \"b\") %>% add_node(type = \"b\", label = \"c\") %>% add_node(type = \"b\", label = \"d\") %>% add_node(type = \"b\", label = \"e\") %>% add_node(type = \"c\", label = \"f\") %>% add_node(type = \"c\", label = \"g\") # Define a 'layout' for groups of nodes # using a text string (dashes are empty # grid cells, numbers--representing # ad-hoc groupings--correspond to # individual nodes); here, define a layout # with 3 groups of nodes layout <- \" 1-------- 1-------- ---222--- --------3 --------3 \" # Use the `layout` along with what nodes # the numbers correspond to in the graph # with the `nodes` named vectors; the # optional `sort` vector describes how # we should sort the collection of node # before adding position information graph <- graph %>% layout_nodes_w_string( layout = layout, nodes = c(\"1\" = \"type:a\", \"2\" = \"type:b\", \"3\" = \"type:c\"), sort = c(\"1\" = \"label:asc\", \"2\" = \"label:desc\", \"3\" = \"label:desc\")) # Show the graph's node data frame # to confirm that `x` and `y` values # were added to each of the nodes graph %>% get_node_df() #> id type label x y #> 1 1 a a 0 8 #> 2 2 a b 0 6 #> 3 3 b c 5 4 #> 4 4 b d 4 4 #> 5 5 b e 3 4 #> 6 6 c f 8 0 #> 7 7 c g 8 2"},{"path":"/reference/mermaid.html","id":null,"dir":"Reference","previous_headings":"","what":"R + mermaid.js — mermaid","title":"R + mermaid.js — mermaid","text":"Make diagrams R using mermaid.js infrastructure provided htmlwidgets.","code":""},{"path":"/reference/mermaid.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"R + mermaid.js — mermaid","text":"","code":"mermaid(diagram = \"\", ..., width = NULL, height = NULL)"},{"path":"/reference/mermaid.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"R + mermaid.js — mermaid","text":"diagram Diagram mermaid markdown-like language file (connection file name) containing diagram specification. diagram provided diagram = \"\" function assume diagram provided htmltools::tags() DiagrammeR just used dependency injection. ... arguments parameters like send JavaScript. width width resulting graphic pixels. height height resulting graphic pixels.","code":""},{"path":"/reference/mermaid.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"R + mermaid.js — mermaid","text":"object class htmlwidget intelligently print HTML variety contexts including R console, within R Markdown documents, within Shiny output bindings.","code":""},{"path":"/reference/mermaid.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"R + mermaid.js — mermaid","text":"","code":"# Create a simple graph running left to right (note # that the whitespace is not important) # DiagrammeR(\" # graph LR # A-->B # A-->C # C-->E # B-->D # C-->D # D-->F # E-->F # \") # Create the equivalent graph but have it running # from top to bottom # DiagrammeR(\" # graph TB # A-->B # A-->C # C-->E # B-->D # C-->D # D-->F # E-->F # \") # Create a graph with different node shapes and # provide fill styles for each node # DiagrammeR(\"graph LR;A(Rounded)-->B[Squared];B-->C{A Decision}; # C-->D[Square One];C-->E[Square Two]; # style A fill:#E5E25F; style B fill:#87AB51; style C fill:#3C8937; # style D fill:#23772C; style E fill:#B6E6E6;\" # ) # Load in the 'mtcars' dataset # data(mtcars) # connections <- sapply( # 1:ncol(mtcars) # ,function(i) { # paste0( # i # ,\"(\",colnames(mtcars)[i],\")---\" # ,i,\"-stats(\" # ,paste0( # names(summary(mtcars[,i])) # ,\": \" # ,unname(summary(mtcars[,i])) # ,collapse=\"
    \" # ) # ,\")\" # ) # } # ) # Create a diagram using the 'connections' object # DiagrammeR( # paste0( # \"graph TD;\", \"\\n\", # paste(connections, collapse = \"\\n\"),\"\\n\", # \"classDef column fill:#0001CC, stroke:#0D3FF3, stroke-width:1px;\" ,\"\\n\", # \"class \", paste0(1:length(connections), collapse = \",\"), \" column;\" # ) # ) # Also with `DiagrammeR()`, you can use tags # from `htmltools` (just make sure to use # `class = \"mermaid\"`) library(htmltools) # diagramSpec = \" # graph LR; # id1(Start)-->id2(Stop); # style id1 fill:#f9f,stroke:#333,stroke-width:4px; # style id2 fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5; # \" # html_print(tagList( # tags$h1(\"R + mermaid.js = Something Special\") # ,tags$pre(diagramSpec) # ,tags$div(class=\"mermaid\", diagramSpec) # ,DiagrammeR() # )) # Create a sequence diagram # DiagrammeR(\" # sequenceDiagram; # customer->>ticket seller: ask for a ticket; # ticket seller->>database: seats; # alt tickets available # database->>ticket seller: ok; # ticket seller->>customer: confirm; # customer->>ticket seller: ok; # ticket seller->>database: book a seat; # ticket seller->>printer: print a ticket; # else sold out # database->>ticket seller: none left; # ticket seller->>customer: sorry; # end # \")"},{"path":"/reference/mutate_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutate a set of edge attribute values — mutate_edge_attrs","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"Within graph's internal edge data frame (edf), mutate numeric edge attribute values using one expressions.","code":""},{"path":"/reference/mutate_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"","code":"mutate_edge_attrs(graph, ...)"},{"path":"/reference/mutate_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"graph graph object class dgr_graph. ... Expressions used mutation edge attributes. LHS expression either existing new edge attribute name. RHS can consist valid R code uses edge attributes variables. Expressions evaluated order provided, , edge attributes created modified ready use subsequent expressions.","code":""},{"path":"/reference/mutate_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/mutate_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"","code":"# Create a graph with 3 edges graph <- create_graph() %>% add_path(n = 4) %>% set_edge_attrs( edge_attr = width, values = c(3.4, 2.3, 7.2)) # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel width #> 1 1 1 2 3.4 #> 2 2 2 3 2.3 #> 3 3 3 4 7.2 # Mutate the `width` edge # attribute, dividing each # value by 2 graph <- graph %>% mutate_edge_attrs( width = width / 2) # Get the graph's internal # edf to show that the edge # attribute `width` had its # values changed graph %>% get_edge_df() #> id from to rel width #> 1 1 1 2 1.70 #> 2 2 2 3 1.15 #> 3 3 3 4 3.60 # Create a new edge attribute, # called `length`, that is the # log of values in `width` plus # 2 (and, also, round all values # to 2 decimal places) graph <- graph %>% mutate_edge_attrs( length = (log(width) + 2) %>% round(2)) # Get the graph's internal edf # to show that the edge attribute # values had been mutated graph %>% get_edge_df() #> id from to rel width length #> 1 1 1 2 1.70 2.53 #> 2 2 2 3 1.15 2.14 #> 3 3 3 4 3.60 3.28 # Create a new edge attribute # called `area`, which is the # product of the `width` and # `length` attributes graph <- graph %>% mutate_edge_attrs( area = width * length) # Get the graph's internal edf # to show that the edge attribute # values had been multiplied # together (with new attr `area`) graph %>% get_edge_df() #> id from to rel width length area #> 1 1 1 2 1.70 2.53 4.301 #> 2 2 2 3 1.15 2.14 2.461 #> 3 3 3 4 3.60 3.28 11.808"},{"path":"/reference/mutate_edge_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"Within graph's internal edge data frame (edf), mutate edge attribute values edges selection using one expressions. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/mutate_edge_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"","code":"mutate_edge_attrs_ws(graph, ...)"},{"path":"/reference/mutate_edge_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"graph graph object class dgr_graph. ... Expressions used mutation edge attributes. LHS expression either existing new edge attribute name. RHS can consist valid R code uses edge attributes variables. Expressions evaluated order provided, , edge attributes created modified ready use subsequent expressions.","code":""},{"path":"/reference/mutate_edge_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/mutate_edge_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"","code":"# Create a graph with 3 edges # and then select edge `1` graph <- create_graph() %>% add_path(n = 4) %>% set_edge_attrs( edge_attr = width, values = c(3.4, 2.3, 7.2)) %>% select_edges(edges = 1) # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel width #> 1 1 1 2 3.4 #> 2 2 2 3 2.3 #> 3 3 3 4 7.2 # Mutate the `width` edge # attribute for the edges # only in the active selection # of edges (edge `1`); here, # we divide each value in the # selection by 2 graph <- graph %>% mutate_edge_attrs_ws( width = width / 2) # Get the graph's internal # edf to show that the edge # attribute `width` had its # values changed graph %>% get_edge_df() #> id from to rel width #> 1 1 1 2 1.7 #> 2 2 2 3 2.3 #> 3 3 3 4 7.2 # Create a new edge attribute, # called `length`, that is the # log of values in `width` plus # 2 (and, also, round all values # to 2 decimal places) graph <- graph %>% clear_selection() %>% select_edges(edges = 2:3) %>% mutate_edge_attrs_ws( length = (log(width) + 2) %>% round(2)) # Get the graph's internal edf # to show that the edge attribute # values had been mutated only # for edges `2` and `3` (since # edge `1` is excluded, an NA # value is applied) graph %>% get_edge_df() #> id from to rel width length #> 1 1 1 2 1.7 NA #> 2 2 2 3 2.3 2.83 #> 3 3 3 4 7.2 3.97 # Create a new edge attribute # called `area`, which is the # product of the `width` and # `length` attributes graph <- graph %>% mutate_edge_attrs_ws( area = width * length) # Get the graph's internal edf # to show that the edge attribute # values had been multiplied # together (with new attr `area`) # for nodes `2` and `3` graph %>% get_edge_df() #> id from to rel width length area #> 1 1 1 2 1.7 NA NA #> 2 2 2 3 2.3 2.83 6.509 #> 3 3 3 4 7.2 3.97 28.584 # We can invert the selection # and mutate edge `1` several # times to get an `area` value # for that edge graph <- graph %>% invert_selection() %>% mutate_edge_attrs_ws( length = (log(width) + 5) %>% round(2), area = width * length) # Get the graph's internal edf # to show that the 2 mutations # occurred for edge `1`, yielding # non-NA values for its edge # attributes without changing # those of the other edges graph %>% get_edge_df() #> id from to rel width length area #> 1 1 1 2 1.7 5.53 9.401 #> 2 2 2 3 2.3 2.83 6.509 #> 3 3 3 4 7.2 3.97 28.584"},{"path":"/reference/mutate_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutate a set of node attribute values — mutate_node_attrs","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"Within graph's internal node data frame (ndf), mutate numeric node attribute values using one expressions.","code":""},{"path":"/reference/mutate_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"","code":"mutate_node_attrs(graph, ...)"},{"path":"/reference/mutate_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"graph graph object class dgr_graph. ... Expressions used mutation node attributes. LHS expression either existing new node attribute name. RHS can consist valid R code uses node attributes variables. Expressions evaluated order provided, , node attributes created modified ready use subsequent expressions.","code":""},{"path":"/reference/mutate_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/mutate_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"","code":"# Create a graph with 3 nodes graph <- create_graph() %>% add_path(n = 3) %>% set_node_attrs( node_attr = width, values = c(1.4, 0.3, 1.1)) # Get the graph's internal ndf # to show which node attributes # are available graph %>% get_node_df() #> id type label width #> 1 1 1 1.4 #> 2 2 2 0.3 #> 3 3 3 1.1 # Mutate the `width` node # attribute, dividing each # value by 2 graph <- graph %>% mutate_node_attrs( width = width / 2) # Get the graph's internal # ndf to show that the node # attribute `width` had its # values changed graph %>% get_node_df() #> id type label width #> 1 1 1 0.70 #> 2 2 2 0.15 #> 3 3 3 0.55 # Create a new node attribute, # called `length`, that is the # log of values in `width` plus # 2 (and, also, round all values # to 2 decimal places) graph <- graph %>% mutate_node_attrs( length = (log(width) + 2) %>% round(2)) # Get the graph's internal ndf # to show that the node attribute # values had been mutated graph %>% get_node_df() #> id type label width length #> 1 1 1 0.70 1.64 #> 2 2 2 0.15 0.10 #> 3 3 3 0.55 1.40 # Create a new node attribute # called `area`, which is the # product of the `width` and # `length` attributes graph <- graph %>% mutate_node_attrs( area = width * length) # Get the graph's internal ndf # to show that the node attribute # values had been multiplied # together (with new attr `area`) graph %>% get_node_df() #> id type label width length area #> 1 1 1 0.70 1.64 1.148 #> 2 2 2 0.15 0.10 0.015 #> 3 3 3 0.55 1.40 0.770"},{"path":"/reference/mutate_node_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"Within graph's internal node data frame (ndf), mutate node attribute values nodes selection using one expressions. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/mutate_node_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"","code":"mutate_node_attrs_ws(graph, ...)"},{"path":"/reference/mutate_node_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"graph graph object class dgr_graph. ... Expressions used mutation node attributes. LHS expression either existing new node attribute name. RHS can consist valid R code uses node attributes variables. Expressions evaluated order provided, , node attributes created modified ready use subsequent expressions.","code":""},{"path":"/reference/mutate_node_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/mutate_node_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"","code":"# Create a graph with 3 nodes # and then select node `1` graph <- create_graph() %>% add_path(n = 3) %>% set_node_attrs( node_attr = width, values = c(1.4, 0.3, 1.1)) %>% select_nodes(nodes = 1) # Get the graph's internal ndf # to show which node attributes # are available graph %>% get_node_df() #> id type label width #> 1 1 1 1.4 #> 2 2 2 0.3 #> 3 3 3 1.1 # Mutate the `width` node # attribute for the nodes # only in the active selection # of nodes (node `1`); here, # we divide each value in the # selection by 2 graph <- graph %>% mutate_node_attrs_ws( width = width / 2) # Get the graph's internal # ndf to show that the node # attribute `width` was # mutated only for node `1` graph %>% get_node_df() #> id type label width #> 1 1 1 0.7 #> 2 2 2 0.3 #> 3 3 3 1.1 # Create a new node attribute, # called `length`, that is the # log of values in `width` plus # 2 (and, also, round all values # to 2 decimal places) graph <- graph %>% clear_selection() %>% select_nodes(nodes = 2:3) %>% mutate_node_attrs_ws( length = (log(width) + 2) %>% round(2)) # Get the graph's internal ndf # to show that the node attribute # values had been mutated only # for nodes `2` and `3` (since # node `1` is excluded, an NA # value is applied) graph %>% get_node_df() #> id type label width length #> 1 1 1 0.7 NA #> 2 2 2 0.3 0.8 #> 3 3 3 1.1 2.1 # Create a new node attribute # called `area`, which is the # product of the `width` and # `length` attributes graph <- graph %>% mutate_node_attrs_ws( area = width * length) # Get the graph's internal ndf # to show that the node attribute # values had been multiplied # together (with new attr `area`) # for nodes `2` and `3` graph %>% get_node_df() #> id type label width length area #> 1 1 1 0.7 NA NA #> 2 2 2 0.3 0.8 0.24 #> 3 3 3 1.1 2.1 2.31 # We can invert the selection # and mutate node `1` several # times to get an `area` value # for that node graph <- graph %>% invert_selection() %>% mutate_node_attrs_ws( length = (log(width) + 5) %>% round(2), area = width * length) # Get the graph's internal ndf # to show that the 2 mutations # occurred for node `1`, yielding # non-NA values for its node # attributes without changing # those of the other nodes graph %>% get_node_df() #> id type label width length area #> 1 1 1 0.7 4.64 3.248 #> 2 2 2 0.3 0.80 0.240 #> 3 3 3 1.1 2.10 2.310"},{"path":"/reference/node_aes.html","id":null,"dir":"Reference","previous_headings":"","what":"Insert node aesthetic attributes during node creation — node_aes","title":"Insert node aesthetic attributes during node creation — node_aes","text":"helper function invoked provide values namesake node_aes argument, present function nodes created.","code":""},{"path":"/reference/node_aes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insert node aesthetic attributes during node creation — node_aes","text":"","code":"node_aes( shape = NULL, style = NULL, penwidth = NULL, color = NULL, fillcolor = NULL, image = NULL, fontname = NULL, fontsize = NULL, fontcolor = NULL, peripheries = NULL, height = NULL, width = NULL, x = NULL, y = NULL, group = NULL, tooltip = NULL, xlabel = NULL, URL = NULL, sides = NULL, orientation = NULL, skew = NULL, distortion = NULL, gradientangle = NULL, fixedsize = NULL, labelloc = NULL, margin = NULL )"},{"path":"/reference/node_aes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insert node aesthetic attributes during node creation — node_aes","text":"shape shape use node. possible shape types include: circle, rectangle, triangle, plaintext, square, polygon. style node line style. style types can used : filled, invisible, diagonals, rounded, dashed, dotted, solid, bold. penwidth thickness stroke line (pt units) node shape. default value 1.0. color color node's outline. Can named colors R knows (obtained using colors() function), , hexadecimal color code. fillcolor color fill shape node. Can named colors R knows (obtained using colors() function), , hexadecimal color code. image reference image location. fontname name system font used node text. fontsize point size font used node text. fontcolor color used node text. Can named colors R knows (obtained using colors() function), , hexadecimal color code. peripheries repeated number node shapes (increasing size) draw node periphery. height height node shape, inches. default value 0.5 whereas minimum value 0.02. understood initial, minimum height node. fixedsize set TRUE, final height node. Otherwise, node label requires height fit, node's height increased contain label. width width node shape, inches. default value 0.5 whereas minimum value 0.02. understood initial, minimum width node. fixedsize set TRUE, final width node. Otherwise, node label requires width fit, node's width increased contain label. x fixed position node x direction. integer-based floating point value accepted. y fixed position node y direction. integer-based floating point value accepted. group node group. tooltip Text node tooltip. xlabel External label node. label placed outside node near . labels added nodes edges placed. labels placed overlap node label. means may possible place . URL URL associate node. Upon rendering plot, clicking nodes associated URLs open URL default browser. sides using shape polygon, value provide number sides polygon. orientation angle, degrees, used rotate nodes shape polygon. polygon shapes (set sides node attribute), value orientation 0 results flat base. skew 0-1 value result node shape skewed right (bottom top). value range 0 -1 skew shape left. distortion distortion factor used shape polygon used. 0-1 value increasingly result top part node polygon shape larger bottom. Moving 0 toward -1 result opposite distortion effect. gradientangle path angle node color fill gradient. fixedsize set FALSE, size node determined smallest width height needed contain label, , margin specified margin node attribute. width height must also least large sizes specified width height node attributes, specify minimum values. set TRUE, node size entirely specified values width height node attributes (.e., node expanded size contain text label). labelloc Sets vertical placement labels nodes clusters. attribute used height node larger height label. labelloc node attribute can set either t (top), c (center), b (bottom). default, label vertically centered. margin Sets amount space around node's label. default, value 0.11,0.055.","code":""},{"path":[]},{"path":"/reference/node_aes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insert node aesthetic attributes during node creation — node_aes","text":"","code":"# Create a new graph and add # a path with several node # aesthetic attributes graph <- create_graph() %>% add_path( n = 3, type = \"path\", node_aes = node_aes( shape = \"circle\", x = c(1, 3, 2), y = c(4, -1, 3) ) ) # View the graph's internal # node data frame; the node # aesthetic attributes have # been inserted graph %>% get_node_df() #> id type label shape x y #> 1 1 path 1 circle 1 4 #> 2 2 path 2 circle 3 -1 #> 3 3 path 3 circle 2 3 # Create a new graph which is # fully connected graph <- create_graph() %>% add_full_graph( n = 4, node_data = node_data(value = 1:4), node_aes = node_aes( x = c(2, 1, 3, 2), y = c(3, 2, 2, 1) ), edge_aes = edge_aes(color = \"blue\") )"},{"path":"/reference/node_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Insert node data attributes during node creation — node_data","title":"Insert node data attributes during node creation — node_data","text":"helper function invoked provide values namesake node_data argument, present function nodes created.","code":""},{"path":"/reference/node_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insert node data attributes during node creation — node_data","text":"","code":"node_data(...)"},{"path":"/reference/node_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insert node data attributes during node creation — node_data","text":"... Node data attributes provided one named vectors.","code":""},{"path":[]},{"path":"/reference/node_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insert node data attributes during node creation — node_data","text":"","code":"# Create a new graph and add # a path with several node # data attributes graph <- create_graph() %>% add_path( n = 3, type = \"path\", node_data = node_data( hour = 5, index = c(1, 3, 2))) # View the graph's internal # node data frame; the node # data attributes have been # inserted graph %>% get_node_df() #> id type label hour index #> 1 1 path 1 5 1 #> 2 2 path 2 5 3 #> 3 3 path 3 5 2"},{"path":"/reference/node_edge_aes_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Options for node and edge aesthetics and data — node_edge_aes_data","title":"Options for node and edge aesthetics and data — node_edge_aes_data","text":"Options node edge aesthetics data","code":""},{"path":"/reference/node_edge_aes_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Options for node and edge aesthetics and data — node_edge_aes_data","text":"node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":[]},{"path":"/reference/node_list_1.html","id":null,"dir":"Reference","previous_headings":"","what":"Node list - Version 1. — node_list_1","title":"Node list - Version 1. — node_list_1","text":"simple, 2-column data frame can used generate graph nodes.","code":""},{"path":"/reference/node_list_1.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Node list - Version 1. — node_list_1","text":"","code":"node_list_1"},{"path":"/reference/node_list_1.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Node list - Version 1. — node_list_1","text":"data frame 10 rows 2 variables: id unique, monotonically increasing integer ID value label unique label associated ID value","code":""},{"path":"/reference/node_list_2.html","id":null,"dir":"Reference","previous_headings":"","what":"Node list - Version 2. — node_list_2","title":"Node list - Version 2. — node_list_2","text":"simple, 5-column data frame can used generate graph nodes.","code":""},{"path":"/reference/node_list_2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Node list - Version 2. — node_list_2","text":"","code":"node_list_2"},{"path":"/reference/node_list_2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Node list - Version 2. — node_list_2","text":"data frame 10 rows 5 variables: id unique, monotonically increasing integer ID value label unique label associated ID value type grouping variable either x, y, z value_1 randomized set numeric values 0 10 value_2 randomized set numeric values 0 10","code":""},{"path":"/reference/nudge_node_positions_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Move layout positions of a selection of nodes — nudge_node_positions_ws","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"active selection nodes, move position either x y directions, . Nodes selection position information (.e., NA values x y node attributes) ignored. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/nudge_node_positions_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"","code":"nudge_node_positions_ws(graph, dx, dy)"},{"path":"/reference/nudge_node_positions_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"graph graph object class dgr_graph. dx single numeric value specifying amount selected nodes (non-NA values x y attributes) moved x direction. positive value move nodes right, negative left. dy single numeric value specifying amount selected nodes (non-NA values x y attributes) moved y direction. positive value move nodes , negative .","code":""},{"path":"/reference/nudge_node_positions_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"graph object class dgr_graph.","code":""},{"path":"/reference/nudge_node_positions_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"","code":"# Create a simple graph with 4 nodes graph <- create_graph() %>% add_node( type = \"a\", label = \"one\") %>% add_node( type = \"a\", label = \"two\") %>% add_node( type = \"b\", label = \"three\") %>% add_node( type = \"b\", label = \"four\") # Add position information to each of # the graph's nodes graph <- graph %>% set_node_position( node = 1, x = 1, y = 1) %>% set_node_position( node = 2, x = 2, y = 2) %>% set_node_position( node = 3, x = 3, y = 3) %>% set_node_position( node = 4, x = 4, y = 4) # Select all of the graph's nodes using the # `select_nodes()` function (and only # specifying the graph object) graph <- select_nodes(graph) # Move the selected nodes (all the nodes, # in this case) 5 units to the right graph <- graph %>% nudge_node_positions_ws( dx = 5, dy = 0) # View the graph's node data frame graph %>% get_node_df() #> id type label x y #> 1 1 a one 6 1 #> 2 2 a two 7 2 #> 3 3 b three 8 3 #> 4 4 b four 9 4 # Now select nodes that have `type == \"b\"` # and move them in the `y` direction 2 units # (the graph still has an active selection # and so it must be cleared first) graph <- graph %>% clear_selection() %>% select_nodes( conditions = type == \"b\") %>% nudge_node_positions_ws( dx = 0, dy = 2) # View the graph's node data frame graph %>% get_node_df() #> id type label x y #> 1 1 a one 6 1 #> 2 2 a two 7 2 #> 3 3 b three 8 5 #> 4 4 b four 9 6"},{"path":"/reference/open_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Read a graph or graph series from disk — open_graph","title":"Read a graph or graph series from disk — open_graph","text":"Load graph graph series object disk.","code":""},{"path":"/reference/open_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read a graph or graph series from disk — open_graph","text":"","code":"open_graph(file)"},{"path":"/reference/open_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read a graph or graph series from disk — open_graph","text":"file filename graph graph series. Optionally, may contain path file.","code":""},{"path":"/reference/open_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read a graph or graph series from disk — open_graph","text":"","code":"# Create an undirected GNP # graph with 100 nodes using # a probability value of 0.05 gnp_graph <- create_graph( directed = FALSE) %>% add_gnp_graph( n = 100, p = 0.05 ) # Save the graph to disk; use # the file name `gnp_graph.dgr` # save_graph( # x = gnp_graph, # file = \"gnp_graph\" # ) # To read the graph file from # disk, use `open_graph()` # gnp_graph_2 <- # open_graph( # file = \"gnp_graph.dgr\" # )"},{"path":"/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"/reference/pipe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pipe operator — %>%","text":"lhs value magrittr placeholder. rhs function call using magrittr semantics.","code":""},{"path":"/reference/pipe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pipe operator — %>%","text":"result calling rhs(lhs).","code":""},{"path":"/reference/print.dgr_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Print the graph to the terminal — print.dgr_graph","title":"Print the graph to the terminal — print.dgr_graph","text":"function provide summary graph.","code":""},{"path":"/reference/print.dgr_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print the graph to the terminal — print.dgr_graph","text":"","code":"# S3 method for dgr_graph print(x, ...)"},{"path":"/reference/print.dgr_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print the graph to the terminal — print.dgr_graph","text":"x graph object class dgr_graph.","code":""},{"path":"/reference/print.dgr_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Print the graph to the terminal — print.dgr_graph","text":"","code":"if (FALSE) { # Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get a summary of the graph graph }"},{"path":"/reference/recode_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Recode a set of edge attribute values — recode_edge_attrs","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"Within graph's internal edge data frame (edf), recode character numeric edge attribute values. Optionally, one can specify replacement value unmatched mappings.","code":""},{"path":"/reference/recode_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"","code":"recode_edge_attrs( graph, edge_attr_from, ..., otherwise = NULL, edge_attr_to = NULL )"},{"path":"/reference/recode_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from name edge attribute column values recoded. ... Single-length character vectors recoding instructions. first component value replace second replacement value (form \"[to_replace] -> [replacement]\", ...). otherwise optional single value recoding unmatched values. edge_attr_to optional name new edge attribute recoded values applied. retain original edge attribute values.","code":""},{"path":"/reference/recode_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/recode_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 6, set_seed = 23) %>% set_edge_attrs( edge_attr = rel, values = c(\"a\", \"b\", \"a\", \"c\", \"b\", \"d\")) # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel #> 1 1 1 3 a #> 2 2 2 4 b #> 3 3 2 3 a #> 4 4 3 1 c #> 5 5 3 4 b #> 6 6 4 3 d # Recode the `rel` node # attribute, creating a new edge # attribute called `penwidth`; # here, `a` is recoded to `1.0`, # `b` maps to `1.5`, and all # other values become `0.5` graph <- graph %>% recode_edge_attrs( edge_attr_from = rel, \"a -> 1.0\", \"b -> 1.5\", otherwise = 0.5, edge_attr_to = penwidth) # Get the graph's internal edf # to show that the node # attribute values had been # recoded and copied into a # new node attribute graph %>% get_edge_df() #> id from to rel penwidth #> 1 1 1 3 a 1.0 #> 2 2 2 4 b 1.5 #> 3 3 2 3 a 1.0 #> 4 4 3 1 c 0.5 #> 5 5 3 4 b 1.5 #> 6 6 4 3 d 0.5"},{"path":"/reference/recode_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Recode a set of node attribute values — recode_node_attrs","title":"Recode a set of node attribute values — recode_node_attrs","text":"Within graph's internal node data frame (ndf), recode character numeric node attribute values. Optionally, one can specify replacement value unmatched mappings.","code":""},{"path":"/reference/recode_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Recode a set of node attribute values — recode_node_attrs","text":"","code":"recode_node_attrs( graph, node_attr_from, ..., otherwise = NULL, node_attr_to = NULL )"},{"path":"/reference/recode_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Recode a set of node attribute values — recode_node_attrs","text":"graph graph object class dgr_graph. node_attr_from name node attribute column values recoded. ... Single-length character vectors recoding instructions. first component value replace second replacement value (form \"[to_replace] -> [replacement]\", ...). otherwise optional single value recoding unmatched values. node_attr_to optional name new node attribute recoded values applied. retain original node attribute values.","code":""},{"path":"/reference/recode_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Recode a set of node attribute values — recode_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/recode_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Recode a set of node attribute values — recode_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) %>% set_node_attrs( node_attr = shape, values = c(\"circle\", \"hexagon\", \"rectangle\", \"rectangle\", \"circle\")) # Get the graph's internal ndf # to show which node # attributes are available graph %>% get_node_df() #> id type label shape #> 1 1 1 circle #> 2 2 2 hexagon #> 3 3 3 rectangle #> 4 4 4 rectangle #> 5 5 5 circle # Recode the `shape` node # attribute, so that `circle` # is recoded to `square` and that # `rectangle` becomes `triangle` graph <- graph %>% recode_node_attrs( node_attr_from = shape, \"circle -> square\", \"rectangle -> triangle\") # Get the graph's internal # ndf to show that the node # attribute values had been recoded graph %>% get_node_df() #> id type label shape #> 1 1 1 square #> 2 2 2 hexagon #> 3 3 3 triangle #> 4 4 4 triangle #> 5 5 5 square # Create a new node attribute, # called `color`, that is based # on a recoding of `shape`; here, # map the square shape to a `red` # color and map all other shapes # to a `green` color graph <- graph %>% recode_node_attrs( node_attr_from = shape, \"square -> red\", otherwise = \"green\", node_attr_to = color) # Get the graph's internal ndf # to see the change graph %>% get_node_df() #> id type label shape color #> 1 1 1 square red #> 2 2 2 hexagon green #> 3 3 3 triangle green #> 4 4 4 triangle green #> 5 5 5 square red"},{"path":"/reference/remove_graph_from_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Remove a graph from a graph series — remove_graph_from_graph_series","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"Remove single graph object set graph objects contained within graph series object.","code":""},{"path":"/reference/remove_graph_from_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"","code":"remove_graph_from_graph_series(graph_series, index = \"last\")"},{"path":"/reference/remove_graph_from_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"graph_series graph series object graph object removed. index index graph object removed graph series object.","code":""},{"path":"/reference/remove_graph_from_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"graph series object type dgr_graph_1D.","code":""},{"path":"/reference/remove_graph_from_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Remove the second graph # from the graph series series <- series %>% remove_graph_from_graph_series( index = 2) # With `get_graph_series_info()`, # we can ensure that a graph # was removed series %>% get_graph_series_info() #> graph name date_time tz nodes edges directed #> 1 1 graph_mkRJxXyq 2023-11-08 15:34:06 UTC 4 3 TRUE #> 2 2 graph_ySz3BP7j 2023-11-08 15:34:06 UTC 6 5 TRUE"},{"path":"/reference/rename_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Rename an edge attribute — rename_edge_attrs","title":"Rename an edge attribute — rename_edge_attrs","text":"Within graph's internal edge data frame (edf), rename existing edge attribute.","code":""},{"path":"/reference/rename_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rename an edge attribute — rename_edge_attrs","text":"","code":"rename_edge_attrs(graph, edge_attr_from, edge_attr_to)"},{"path":"/reference/rename_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rename an edge attribute — rename_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from name edge attribute renamed. edge_attr_to new name edge attribute column identified edge_attr_from.","code":""},{"path":"/reference/rename_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Rename an edge attribute — rename_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rename_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rename an edge attribute — rename_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 8, set_seed = 23) %>% set_edge_attrs( edge_attr = color, values = \"green\") # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel color #> 1 1 1 3 green #> 2 2 2 1 green #> 3 3 2 5 green #> 4 4 2 3 green #> 5 5 3 2 green #> 6 6 3 5 green #> 7 7 3 4 green #> 8 8 5 3 green # Rename the `color` node # attribute as `weight` graph <- graph %>% rename_edge_attrs( edge_attr_from = color, edge_attr_to = labelfontcolor) # Get the graph's internal # edf to show that the edge # attribute had been renamed graph %>% get_edge_df() #> id from to rel labelfontcolor #> 1 1 1 3 green #> 2 2 2 1 green #> 3 3 2 5 green #> 4 4 2 3 green #> 5 5 3 2 green #> 6 6 3 5 green #> 7 7 3 4 green #> 8 8 5 3 green"},{"path":"/reference/rename_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Rename a node attribute — rename_node_attrs","title":"Rename a node attribute — rename_node_attrs","text":"Within graph's internal node data frame (ndf), rename existing node attribute.","code":""},{"path":"/reference/rename_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rename a node attribute — rename_node_attrs","text":"","code":"rename_node_attrs(graph, node_attr_from, node_attr_to)"},{"path":"/reference/rename_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rename a node attribute — rename_node_attrs","text":"graph graph object class dgr_graph. node_attr_from name node attribute renamed. node_attr_to new name node attribute column identified node_attr_from.","code":""},{"path":"/reference/rename_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Rename a node attribute — rename_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rename_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rename a node attribute — rename_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 8, set_seed = 23) %>% set_node_attrs( node_attr = shape, values = \"circle\") %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the graph's internal ndf # to show which node attributes # are available graph %>% get_node_df() #> id type label shape value #> 1 1 1 circle 5.2 #> 2 2 2 circle 5.3 #> 3 3 3 circle 4.4 #> 4 4 4 circle 5.8 #> 5 5 5 circle 5.9 # Rename the `value` node # attribute as `weight` graph <- graph %>% rename_node_attrs( node_attr_from = value, node_attr_to = weight) # Get the graph's internal # ndf to show that the node # attribute had been renamed graph %>% get_node_df() #> id type label shape weight #> 1 1 1 circle 5.2 #> 2 2 2 circle 5.3 #> 3 3 3 circle 4.4 #> 4 4 4 circle 5.8 #> 5 5 5 circle 5.9"},{"path":"/reference/renderDiagrammeR.html","id":null,"dir":"Reference","previous_headings":"","what":"Widget render function for use in Shiny — renderDiagrammeR","title":"Widget render function for use in Shiny — renderDiagrammeR","text":"Widget render function use Shiny","code":""},{"path":"/reference/renderDiagrammeR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Widget render function for use in Shiny — renderDiagrammeR","text":"","code":"renderDiagrammeR(expr, env = parent.frame(), quoted = FALSE)"},{"path":"/reference/renderDiagrammeR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Widget render function for use in Shiny — renderDiagrammeR","text":"expr expression generates DiagrammeR graph env environment evaluate expr. quoted expr quoted expression (quote())? useful want save expression variable.","code":""},{"path":"/reference/renderGrViz.html","id":null,"dir":"Reference","previous_headings":"","what":"Widget render function for use in Shiny — renderGrViz","title":"Widget render function for use in Shiny — renderGrViz","text":"Widget render function use Shiny","code":""},{"path":"/reference/renderGrViz.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Widget render function for use in Shiny — renderGrViz","text":"","code":"renderGrViz(expr, env = parent.frame(), quoted = FALSE)"},{"path":"/reference/renderGrViz.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Widget render function for use in Shiny — renderGrViz","text":"expr expression generates DiagrammeR graph env environment evaluate expr. quoted expr quoted expression (quote())? useful want save expression variable.","code":""},{"path":[]},{"path":"/reference/render_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Render the graph in various formats — render_graph","title":"Render the graph in various formats — render_graph","text":"Using dgr_graph object, render graph RStudio Viewer.","code":""},{"path":"/reference/render_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render the graph in various formats — render_graph","text":"","code":"render_graph( graph, layout = NULL, output = NULL, as_svg = FALSE, title = NULL, width = NULL, height = NULL )"},{"path":"/reference/render_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render the graph in various formats — render_graph","text":"graph graph object class dgr_graph. layout string specifying layout type use node placement rendering. Possible layouts include: nicely, circle, tree, kk, fr. output string specifying output type; graph (default) renders graph using grViz() function visNetwork renders graph using visnetwork() function. as_svg option render graph SVG document. title optional title graph using output = \"graph\". width optional parameter specifying width resulting graphic pixels. height optional parameter specifying height resulting graphic pixels.","code":""},{"path":[]},{"path":"/reference/render_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render the graph in various formats — render_graph","text":"","code":"if (interactive()) { # Render a graph that's a # balanced tree create_graph() %>% add_balanced_tree( k = 2, h = 3) %>% render_graph() # Use the `tree` layout for # better node placement in this # hierarchical graph create_graph() %>% add_balanced_tree( k = 2, h = 3) %>% render_graph(layout = \"tree\") # Plot the same tree graph but # don't show the node ID values create_graph() %>% add_balanced_tree( k = 2, h = 3) %>% set_node_attr_to_display() %>% render_graph(layout = \"tree\") # Create a circle graph create_graph() %>% add_gnm_graph( n = 55, m = 75, set_seed = 23) %>% render_graph( layout = \"circle\") # Render the graph using the # `visNetwork` output option create_graph() %>% add_balanced_tree( k = 2, h = 3) %>% render_graph( output = \"visNetwork\") }"},{"path":"/reference/render_graph_from_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a graph available in a series — render_graph_from_graph_series","title":"Render a graph available in a series — render_graph_from_graph_series","text":"Using graph series object type dgr_graph_1D, either render graph Viewer output various formats.","code":""},{"path":"/reference/render_graph_from_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a graph available in a series — render_graph_from_graph_series","text":"","code":"render_graph_from_graph_series( graph_series, graph_no, output = \"graph\", width = NULL, height = NULL )"},{"path":"/reference/render_graph_from_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a graph available in a series — render_graph_from_graph_series","text":"graph_series graph series object type dgr_graph_1D. graph_no index graph graph series. output string specifying output type; graph (default) renders graph using grViz() function visNetwork renders graph using visnetwork() function. width optional parameter specifying width resulting graphic pixels. height optional parameter specifying height resulting graphic pixels.","code":""},{"path":[]},{"path":"/reference/render_graph_from_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render a graph available in a series — render_graph_from_graph_series","text":"","code":"if (FALSE) { # Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # View the second graph in # the series in the Viewer render_graph_from_graph_series( graph_series = series, graph_no = 2) }"},{"path":"/reference/reorder_graph_actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Reorder the stored series of graph actions — reorder_graph_actions","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"Reorder graph actions stored graph use add_graph_action() function. actions invoked specified order via trigger_graph_actions() function.","code":""},{"path":"/reference/reorder_graph_actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"","code":"reorder_graph_actions(graph, indices)"},{"path":"/reference/reorder_graph_actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"graph graph object class dgr_graph. indices numeric vector provides new ordering graph actions. vector can length number graph actions, , shorter length. latter case, ordering places given items first remaining actions follow.","code":""},{"path":"/reference/reorder_graph_actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"graph object class dgr_graph.","code":""},{"path":"/reference/reorder_graph_actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) # Add three graph actions to the # graph graph <- graph %>% add_graph_action( fcn = \"rescale_node_attrs\", node_attr_from = \"pagerank\", node_attr_to = \"width\", action_name = \"pgrnk_to_width\") %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\", action_name = \"get_pagerank\") %>% add_graph_action( fcn = \"colorize_node_attrs\", node_attr_from = \"width\", node_attr_to = \"fillcolor\", action_name = \"pgrnk_fillcolor\") # View the graph actions for the graph # object by using the function called # `get_graph_actions()` graph %>% get_graph_actions() #> # A tibble: 3 × 3 #> action_index action_name expression #> #> 1 1 pgrnk_to_width rescale_node_attrs(graph = graph, node_attr_from… #> 2 2 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_fcn… #> 3 3 pgrnk_fillcolor colorize_node_attrs(graph = graph, node_attr_fro… # We note that the order isn't # correct and that the `get_pagerank` # action should be the 1st action # and `pgrnk_to_width` should go # in 2nd place; to fix this, use the # function `reorder_graph_actions()` # and specify the reordering with a # numeric vector graph <- graph %>% reorder_graph_actions( indices = c(2, 1, 3)) # View the graph actions for the graph # object once again to verify that # we have the desired order of actions graph %>% get_graph_actions() #> # A tibble: 3 × 3 #> action_index action_name expression #> #> 1 1 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_fcn… #> 2 2 pgrnk_to_width rescale_node_attrs(graph = graph, node_attr_from… #> 3 3 pgrnk_fillcolor colorize_node_attrs(graph = graph, node_attr_fro…"},{"path":"/reference/replace_in_spec.html","id":null,"dir":"Reference","previous_headings":"","what":"Razor-like template for diagram specification — replace_in_spec","title":"Razor-like template for diagram specification — replace_in_spec","text":"Use Razor-like syntax define template use grViz diagram.","code":""},{"path":"/reference/replace_in_spec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Razor-like template for diagram specification — replace_in_spec","text":"","code":"replace_in_spec(spec, envir = parent.frame())"},{"path":"/reference/replace_in_spec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Razor-like template for diagram specification — replace_in_spec","text":"spec String spec parsed evaluated. envir environment substitution functionality takes place.","code":""},{"path":"/reference/replace_in_spec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Razor-like template for diagram specification — replace_in_spec","text":"","code":"if (FALSE) { # a simple example to use a LETTER as a node label spec <- \" digraph { '@1' } [1]: LETTERS[1] \" grViz(replace_in_spec(spec)) spec <- \" digraph a_nice_graph { node [fontname = Helvetica] a [label = '@1'] b [label = '@2-1'] c [label = '@2-2'] d [label = '@2-3'] e [label = '@2-4'] f [label = '@2-5'] g [label = '@2-6'] h [label = '@2-7'] i [label = '@2-8'] j [label = '@2-9'] a -> { b c d e f g h i j} } [1]: 'top' [2]: 10:20 \" grViz(replace_in_spec(spec)) }"},{"path":"/reference/rescale_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Rescale numeric edge attribute values — rescale_edge_attrs","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"graph object class dgr_graph, take set numeric values edge attribute, rescale new numeric color range, write edge attribute new edge attribute column.","code":""},{"path":"/reference/rescale_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"","code":"rescale_edge_attrs( graph, edge_attr_from, to_lower_bound = 0, to_upper_bound = 1, edge_attr_to = NULL, from_lower_bound = NULL, from_upper_bound = NULL )"},{"path":"/reference/rescale_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from edge attribute containing numeric data rescaled new numeric color values. to_lower_bound lower bound value set rescaled values. can numeric value X11 color name. to_upper_bound upper bound value set rescaled values. can numeric value X11 color name. edge_attr_to optional name new edge attribute recoded values applied. retain original edge attribute values. from_lower_bound optional, manually set lower bound value rescaled values. set, minimum value set used. from_upper_bound optional, manually set upper bound value rescaled values. set, minimum value set used.","code":""},{"path":"/reference/rescale_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rescale_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 7, set_seed = 23) %>% set_edge_attrs( edge_attr = weight, values = rnorm( n = count_edges(.), mean = 5, sd = 1)) # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel weight #> 1 1 2 8 5.045437 #> 2 2 4 2 6.575780 #> 3 3 4 6 5.218288 #> 4 4 4 9 3.953465 #> 5 5 6 5 4.711311 #> 6 6 6 10 5.481550 #> 7 7 10 9 3.783624 # Rescale the `weight` edge # attribute, so that its values # are rescaled between 0 and 1 graph <- graph %>% rescale_edge_attrs( edge_attr_from = weight, to_lower_bound = 0, to_upper_bound = 1) # Get the graph's internal edf # to show that the edge attribute # values had been rescaled graph %>% get_edge_df() #> id from to rel weight #> 1 1 2 8 0.452 #> 2 2 4 2 1.000 #> 3 3 4 6 0.514 #> 4 4 4 9 0.061 #> 5 5 6 5 0.332 #> 6 6 6 10 0.608 #> 7 7 10 9 0.000 # Scale the values in the `weight` # edge attribute to different # shades of gray for the `color` # edge attribute and different # numerical values for the # `penwidth` attribute graph <- graph %>% rescale_edge_attrs( edge_attr_from = weight, to_lower_bound = \"gray80\", to_upper_bound = \"gray20\", edge_attr_to = color) %>% rescale_edge_attrs( edge_attr_from = weight, to_lower_bound = 0.5, to_upper_bound = 3, edge_attr_to = penwidth) # Get the graph's internal edf # once more to show that scaled # grayscale colors are now available # in `color` and scaled numerical # values are in the `penwidth` # edge attribute graph %>% get_edge_df() #> id from to rel weight color penwidth #> 1 1 2 8 0.452 #838383 1.630 #> 2 2 4 2 1.000 #333333 3.000 #> 3 3 4 6 0.514 #797979 1.785 #> 4 4 4 9 0.061 #C2C2C2 0.652 #> 5 5 6 5 0.332 #959595 1.330 #> 6 6 6 10 0.608 #6B6B6B 2.020 #> 7 7 10 9 0.000 #CCCCCC 0.500"},{"path":"/reference/rescale_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Rescale numeric node attribute values — rescale_node_attrs","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"graph object class dgr_graph, take set numeric values node attribute, rescale new numeric color range, write node attribute new node attribute column.","code":""},{"path":"/reference/rescale_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"","code":"rescale_node_attrs( graph, node_attr_from, to_lower_bound = 0, to_upper_bound = 1, node_attr_to = NULL, from_lower_bound = NULL, from_upper_bound = NULL )"},{"path":"/reference/rescale_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"graph graph object class dgr_graph. node_attr_from node attribute containing numeric data rescaled new numeric color values. to_lower_bound lower bound value set rescaled values. can numeric value X11 color name. to_upper_bound upper bound value set rescaled values. can numeric value X11 color name. node_attr_to optional name new node attribute recoded values applied. retain original node attribute values. from_lower_bound optional, manually set lower bound value rescaled values. set, minimum value set used. from_upper_bound optional, manually set upper bound value rescaled values. set, minimum value set used.","code":""},{"path":"/reference/rescale_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rescale_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the graph's internal ndf # to show which node attributes # are available graph %>% get_node_df() #> id type label value #> 1 1 1 5.3 #> 2 2 2 4.4 #> 3 3 3 5.8 #> 4 4 4 5.9 #> 5 5 5 6.2 # Rescale the `value` node # attribute, so that its values # are rescaled between 0 and 1 graph <- graph %>% rescale_node_attrs( node_attr_from = value, to_lower_bound = 0, to_upper_bound = 1) # Get the graph's internal ndf # to show that the node attribute # values had been rescaled graph %>% get_node_df() #> id type label value #> 1 1 1 0.500 #> 2 2 2 0.000 #> 3 3 3 0.778 #> 4 4 4 0.833 #> 5 5 5 1.000 # Scale the values in the `value` # node attribute to different # shades of gray for the `fillcolor` # and `fontcolor` node attributes graph <- graph %>% rescale_node_attrs( node_attr_from = value, to_lower_bound = \"gray80\", to_upper_bound = \"gray20\", node_attr_to = fillcolor) %>% rescale_node_attrs( node_attr_from = value, to_lower_bound = \"gray5\", to_upper_bound = \"gray95\", node_attr_to = fontcolor) # Get the graph's internal ndf # once more to show that scaled # grayscale colors are now available # in the `fillcolor` and `fontcolor` # node attributes graph %>% get_node_df() #> id type label value fillcolor fontcolor #> 1 1 1 0.500 #7B7B7B #767676 #> 2 2 2 0.000 #CCCCCC #0D0D0D #> 3 3 3 0.778 #525252 #B9B9B9 #> 4 4 4 0.833 #4A4A4A #C7C7C7 #> 5 5 5 1.000 #333333 #F2F2F2"},{"path":"/reference/rev_edge_dir.html","id":null,"dir":"Reference","previous_headings":"","what":"Reverse the direction of all edges in a graph — rev_edge_dir","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"Using directed graph input, reverse direction edges graph.","code":""},{"path":"/reference/rev_edge_dir.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"","code":"rev_edge_dir(graph)"},{"path":"/reference/rev_edge_dir.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/rev_edge_dir.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rev_edge_dir.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"","code":"# Create a graph with a # directed tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Inspect the graph's edges graph %>% get_edges() #> [1] \"1->2\" \"1->3\" \"2->4\" \"2->5\" \"3->6\" \"3->7\" # Reverse the edge directions # such that edges are directed # toward the root of the tree graph <- graph %>% rev_edge_dir() # Inspect the graph's edges # after their reversal graph %>% get_edges() #> [1] \"2->1\" \"3->1\" \"4->2\" \"5->2\" \"6->3\" \"7->3\""},{"path":"/reference/rev_edge_dir_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"Using directed graph selection edges input, reverse direction selected edges input graph. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/rev_edge_dir_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"","code":"rev_edge_dir_ws(graph)"},{"path":"/reference/rev_edge_dir_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/rev_edge_dir_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rev_edge_dir_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"","code":"# Create a graph with a # directed tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Inspect the graph's edges graph %>% get_edges() #> [1] \"1->2\" \"1->3\" \"2->4\" \"2->5\" \"3->6\" \"3->7\" # Select all edges associated # with nodes `1` and `2` graph <- graph %>% select_edges_by_node_id( nodes = 1:2) # Reverse the edge directions # of the edges associated with # nodes `1` and `2` graph <- graph %>% rev_edge_dir_ws() # Inspect the graph's edges # after their reversal graph %>% get_edges() #> [1] \"2->1\" \"3->1\" \"4->2\" \"5->2\" \"3->6\" \"3->7\""},{"path":"/reference/save_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Save a graph or graph series to disk — save_graph","title":"Save a graph or graph series to disk — save_graph","text":"Save graph graph series object disk.","code":""},{"path":"/reference/save_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Save a graph or graph series to disk — save_graph","text":"","code":"save_graph(x, file)"},{"path":"/reference/save_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Save a graph or graph series to disk — save_graph","text":"x graph object class dgr_graph graph series object type dgr_graph_1D. file file name graph graph series. Provide character string .dgr extension applied .","code":""},{"path":[]},{"path":"/reference/save_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Save a graph or graph series to disk — save_graph","text":"","code":"# Create an undirected GNP # graph with 100 nodes using # a probability value of 0.05 gnp_graph <- create_graph( directed = FALSE) %>% add_gnp_graph( n = 100, p = 0.05) # Save the graph to disk; use # the file name `gnp_graph.dgr` # save_graph( # x = gnp_graph, # file = \"gnp_graph\" # ) # To read the graph file from # disk, use `open_graph()` # gnp_graph_2 <- # open_graph( # file = \"gnp_graph.dgr\" # )"},{"path":"/reference/select_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Select edges in a graph — select_edges","title":"Select edges in a graph — select_edges","text":"Select edges graph object class dgr_graph.","code":""},{"path":"/reference/select_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select edges in a graph — select_edges","text":"","code":"select_edges( graph, conditions = NULL, set_op = \"union\", from = NULL, to = NULL, edges = NULL )"},{"path":"/reference/select_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select edges in a graph — select_edges","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval edges. set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists. optional vector node IDs edge outgoing filtering list edges present graph. optional vector node IDs edge incoming filtering list edges present graph. edges optional vector edge IDs filtering list edges present graph.","code":""},{"path":"/reference/select_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select edges in a graph — select_edges","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select edges in a graph — select_edges","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"basic\", label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = c(\"a\", \"z\", \"a\"), value = c(6.4, 2.9, 5.0)) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Explicitly select the edge `1`->`4` graph <- graph %>% select_edges( from = 1, to = 4) # Verify that an edge selection has been made # using the `get_selection()` function graph %>% get_selection() #> [1] 1 # Select edges based on the relationship label # being `z` graph <- graph %>% clear_selection() %>% select_edges( conditions = rel == \"z\") # Verify that an edge selection has been made, and # recall that the `2`->`3` edge uniquely has the # `z` relationship label graph %>% get_selection() #> [1] 2 # Select edges based on the edge value attribute # being greater than 3.0 (first clearing the current # selection of edges) graph <- graph %>% clear_selection() %>% select_edges( conditions = value > 3.0) # Verify that the correct edge selection has been # made; in this case, edges `1`->`4` and # `3`->`1` have values for `value` > 3.0 graph %>% get_selection() #> [1] 1 3"},{"path":"/reference/select_edges_by_edge_id.html","id":null,"dir":"Reference","previous_headings":"","what":"Select edges in a graph using edge ID values — select_edges_by_edge_id","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"Select edges graph object class dgr_graph using edge ID values.","code":""},{"path":"/reference/select_edges_by_edge_id.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"","code":"select_edges_by_edge_id(graph, edges, set_op = \"union\")"},{"path":"/reference/select_edges_by_edge_id.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"graph graph object class dgr_graph. edges vector edge IDs selection edges present graph. set_op set operation perform upon consecutive selections graph edges can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_edges_by_edge_id.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_edges_by_edge_id.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"","code":"# Create a graph with 5 nodes graph <- create_graph() %>% add_path(n = 5) # Create a graph selection by selecting # edges with edge IDs `1` and `2` graph <- graph %>% select_edges_by_edge_id( edges = 1:2) # Get the selection of edges graph %>% get_selection() #> [1] 1 2 # Perform another selection of edges, # with edge IDs `1`, `2`, and `4` graph <- graph %>% clear_selection() %>% select_edges_by_edge_id( edges = c(1, 2, 4)) # Get the selection of edges graph %>% get_selection() #> [1] 1 2 4 # Get the fraction of edges selected # over all the edges in the graph graph %>% { l <- get_selection(.) %>% length(.) e <- count_edges(.) l/e } #> [1] 0.75"},{"path":"/reference/select_edges_by_node_id.html","id":null,"dir":"Reference","previous_headings":"","what":"Select edges in a graph using node ID values — select_edges_by_node_id","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"Select edges graph object class dgr_graph using node ID values. edges associated provided nodes included selection.","code":""},{"path":"/reference/select_edges_by_node_id.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"","code":"select_edges_by_node_id(graph, nodes, set_op = \"union\")"},{"path":"/reference/select_edges_by_node_id.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"graph graph object class dgr_graph. nodes vector node IDs selection edges present graph. set_op set operation perform upon consecutive selections graph edges can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_edges_by_node_id.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_edges_by_node_id.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"","code":"# Create a graph with 5 nodes graph <- create_graph() %>% add_path(n = 5) # Create a graph selection by selecting edges # associated with nodes `1` and `2` graph <- graph %>% select_edges_by_node_id( nodes = 1:2) # Get the selection of edges graph %>% get_selection() #> [1] 1 2 # Perform another selection of edges, with nodes # `1`, `2`, and `4` graph <- graph %>% clear_selection() %>% select_edges_by_node_id( nodes = c(1, 2, 4)) # Get the selection of edges graph %>% get_selection() #> [1] 1 2 3 4 # Get a fraction of the edges selected over all # the edges in the graph graph %>% { l <- get_selection(.) %>% length(.) e <- count_edges(.) l/e } #> [1] 1"},{"path":"/reference/select_last_edges_created.html","id":null,"dir":"Reference","previous_headings":"","what":"Select the last set of edges created in a graph — select_last_edges_created","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"Select last edges created graph object class dgr_graph. function ideally used just creating edges selected.","code":""},{"path":"/reference/select_last_edges_created.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"","code":"select_last_edges_created(graph)"},{"path":"/reference/select_last_edges_created.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/select_last_edges_created.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_last_edges_created.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"","code":"# Create a graph and add a cycle and then # a tree in 2 separate function calls graph <- create_graph() %>% add_cycle( n = 3, rel = \"a\") %>% add_balanced_tree( k = 2, h = 2, rel = \"b\") # Select the last edges created (all edges # from the tree) and then set their edge # color to be `red` graph <- graph %>% select_last_edges_created() %>% set_edge_attrs_ws( edge_attr = color, value = \"red\") %>% clear_selection() # Display the graph's internal edge # data frame to verify the change graph %>% get_edge_df() #> id from to rel color #> 1 1 1 2 a #> 2 2 2 3 a #> 3 3 3 1 a #> 4 4 4 5 b red #> 5 5 4 6 b red #> 6 6 5 7 b red #> 7 7 5 8 b red #> 8 8 6 9 b red #> 9 9 6 10 b red"},{"path":"/reference/select_last_nodes_created.html","id":null,"dir":"Reference","previous_headings":"","what":"Select the last set of nodes created in a graph — select_last_nodes_created","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"Select last nodes created graph object class dgr_graph. function ideally used just creating nodes selected.","code":""},{"path":"/reference/select_last_nodes_created.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"","code":"select_last_nodes_created(graph)"},{"path":"/reference/select_last_nodes_created.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/select_last_nodes_created.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_last_nodes_created.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"","code":"# Create a graph and add 4 nodes # in 2 separate function calls graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"a_1\", \"a_2\")) %>% add_n_nodes( n = 2, type = \"b\", label = c(\"b_1\", \"b_2\")) # Select the last nodes created (2 nodes # from the last function call) and then # set their color to be `red` graph <- graph %>% select_last_nodes_created() %>% set_node_attrs_ws( node_attr = color, value = \"red\") %>% clear_selection() # Display the graph's internal node # data frame to verify the change graph %>% get_node_df() #> id type label color #> 1 1 a a_1 #> 2 2 a a_2 #> 3 3 b b_1 red #> 4 4 b b_2 red"},{"path":"/reference/select_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Select nodes in a graph — select_nodes","title":"Select nodes in a graph — select_nodes","text":"Select nodes graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select nodes in a graph — select_nodes","text":"","code":"select_nodes(graph, conditions = NULL, set_op = \"union\", nodes = NULL)"},{"path":"/reference/select_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select nodes in a graph — select_nodes","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval nodes. set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists. nodes optional vector node IDs filtering list nodes present graph.","code":""},{"path":"/reference/select_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select nodes in a graph — select_nodes","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select nodes in a graph — select_nodes","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = c(\"a\", \"a\", \"z\", \"z\"), label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = c(\"a\", \"z\", \"a\")) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Explicitly select nodes `1` and `3` graph <- graph %>% select_nodes(nodes = c(1, 3)) # Verify that the node selection has been made # using the `get_selection()` function graph %>% get_selection() #> [1] 1 3 # Select nodes based on the node `type` # being `z` graph <- graph %>% clear_selection() %>% select_nodes( conditions = type == \"z\") # Verify that an node selection has been made, and # recall that the `3` and `4` nodes are of the # `z` type graph %>% get_selection() #> [1] 3 4 # Select edges based on the node value attribute # being greater than 3.0 (first clearing the current # selection of nodes) graph <- graph %>% clear_selection() %>% select_nodes( conditions = value > 3.0) # Verify that the correct node selection has been # made; in this case, nodes `1` and `3` have values # for `value` greater than 3.0 graph %>% get_selection() #> [1] 1 3"},{"path":"/reference/select_nodes_by_degree.html","id":null,"dir":"Reference","previous_headings":"","what":"Select nodes in the graph based on their degree values — select_nodes_by_degree","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"Using graph object class dgr_graph, create selection nodes certain degree values.","code":""},{"path":"/reference/select_nodes_by_degree.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"","code":"select_nodes_by_degree(graph, expressions, set_op = \"union\")"},{"path":"/reference/select_nodes_by_degree.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"graph graph object class dgr_graph. expressions One expressions filtering nodes degree values. Use combination degree type (deg total degree, indeg -degree, outdeg -degree) comparison operator values comparison (e.g., use \"deg >= 2\" select nodes degree greater equal 2). set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_nodes_by_degree.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes_by_degree.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"","code":"# Create a random graph using # the `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 35, m = 125, set_seed = 23) # Report which nodes have a # total degree (in-degree + # out-degree) of exactly 9 graph %>% select_nodes_by_degree( expressions = \"deg == 9\") %>% get_selection() #> [1] 5 10 26 31 # Report which nodes have a # total degree greater than or # equal to 9 graph %>% select_nodes_by_degree( expressions = \"deg >= 9\") %>% get_selection() #> [1] 1 2 4 5 10 12 18 25 26 31 # Combine two calls of # `select_nodes_by_degree()` to # get those nodes with total # degree less than 3 and total # degree greater than 10 (by # default, those `select...()` # functions will `union` the # sets of nodes selected) graph %>% select_nodes_by_degree( expressions = \"deg < 3\") %>% select_nodes_by_degree( expressions = \"deg > 10\") %>% get_selection() #> [1] 1 2 # Combine two calls of # `select_nodes_by_degree()` to # get those nodes with total # degree greater than or equal # to 3 and less than or equal # to 10 (the key here is to # `intersect` the sets of nodes # selected in the second call) graph %>% select_nodes_by_degree( expressions = \"deg >= 3\") %>% select_nodes_by_degree( expressions = \"deg <= 10\", set_op = \"intersect\") %>% get_selection() #> [1] 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 #> [26] 28 29 30 31 32 33 34 35 # Select all nodes with an # in-degree greater than 5, then, # apply a node attribute to those # selected nodes (coloring the # selected nodes red) graph_2 <- graph %>% select_nodes_by_degree( expressions = \"indeg > 5\") %>% set_node_attrs_ws( node_attr = color, value = \"red\") # Get the selection of nodes graph_2 %>% get_selection() #> [1] 1 4 13 25 35"},{"path":"/reference/select_nodes_by_id.html","id":null,"dir":"Reference","previous_headings":"","what":"Select nodes in a graph by their ID values — select_nodes_by_id","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"Select nodes graph object class dgr_graph node ID values. nodes IDs monotonically increasing integer values, numeric ranges can used selection.","code":""},{"path":"/reference/select_nodes_by_id.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"","code":"select_nodes_by_id(graph, nodes, set_op = \"union\")"},{"path":"/reference/select_nodes_by_id.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"graph graph object class dgr_graph. nodes vector node IDs selection nodes present graph. set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_nodes_by_id.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes_by_id.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df(n = 10) # Create a graph graph <- create_graph( nodes_df = ndf) # Select nodes `1` to `5` and show that # selection of nodes with `get_selection()` graph %>% select_nodes_by_id(nodes = 1:5) %>% get_selection() #> [1] 1 2 3 4 5"},{"path":"/reference/select_nodes_in_neighborhood.html","id":null,"dir":"Reference","previous_headings":"","what":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"Select nodes neighborhood nodes connected specified distance initial node.","code":""},{"path":"/reference/select_nodes_in_neighborhood.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"","code":"select_nodes_in_neighborhood(graph, node, distance, set_op = \"union\")"},{"path":"/reference/select_nodes_in_neighborhood.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"graph graph object class dgr_graph. node node traversal originate. distance maximum number steps node inclusion selection. set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_nodes_in_neighborhood.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes_in_neighborhood.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"","code":"# Create a graph containing # a balanced tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Create a graph selection by # selecting nodes in the # neighborhood of node `1`, where # the neighborhood is limited by # nodes that are 1 connection # away from node `1` graph <- graph %>% select_nodes_in_neighborhood( node = 1, distance = 1) # Get the selection of nodes graph %>% get_selection() #> [1] 1 2 3 # Perform another selection # of nodes, this time with a # neighborhood spanning 2 nodes # from node `1` graph <- graph %>% clear_selection() %>% select_nodes_in_neighborhood( node = 1, distance = 2) # Get the selection of nodes graph %>% get_selection() #> [1] 1 2 3 4 5 6 7"},{"path":"/reference/set_cache.html","id":null,"dir":"Reference","previous_headings":"","what":"Cache a vector in the graph — set_cache","title":"Cache a vector in the graph — set_cache","text":"Place vector cache graph object class dgr_graph.","code":""},{"path":"/reference/set_cache.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cache a vector in the graph — set_cache","text":"","code":"set_cache(graph, to_cache, name = NULL, col = NULL)"},{"path":"/reference/set_cache.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cache a vector in the graph — set_cache","text":"graph graph object class dgr_graph. to_cache vector data frame. data frame supplied single column vector pull must provided col argument. name optional name cached vector. col data frame provided to_cache column name data frame must provided .","code":""},{"path":"/reference/set_cache.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cache a vector in the graph — set_cache","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_cache.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cache a vector in the graph — set_cache","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 22, set_seed = 23 ) # Get the closeness values for # all nodes from `1` to `10` and # store in the graph's cache graph <- graph %>% set_cache( name = \"closeness_vector\", to_cache = get_closeness(.), col = \"closeness\" ) # Get the graph's cache graph %>% get_cache(name = \"closeness_vector\") #> [1] 0.07692308 0.08333333 0.07692308 0.06666667 0.05555556 0.06250000 #> [7] 0.06666667 0.05000000 0.06666667 0.04761905 # Get the difference of betweenness # and closeness values for nodes in # the graph and store the vector in # the graph's cache graph <- graph %>% set_cache( name = \"difference\", to_cache = get_betweenness(.)$betweenness - get_closeness(.)$closeness ) # Get the graph's cache graph %>% get_cache(name = \"difference\") #> [1] 9.25641026 28.91666667 19.08974359 2.60000000 0.44444444 17.93750000 #> [7] 11.93333333 -0.05000000 10.26666667 -0.04761905"},{"path":"/reference/set_edge_attr_to_display.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the edge attribute values to be rendered — set_edge_attr_to_display","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"Set edge attribute type display edge text calling render_graph() function. allows display different types edge attribute values per-edge basis. Without setting display attribute, rendering graph default printing text edges. Setting display edge attribute function first time (.e., display column exist graph's internal edge data frame) insert attr value edges specified edges default value (default) remaining edges.","code":""},{"path":"/reference/set_edge_attr_to_display.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"","code":"set_edge_attr_to_display(graph, attr = NULL, edges = NULL, default = \"label\")"},{"path":"/reference/set_edge_attr_to_display.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"graph graph object class dgr_graph. attr name attribute label text edge obtained. set NULL, NA values assigned display column chosen edges. edges length vector containing one several edge ID values (integers) edge attributes set display rendered graph. NULL, edges graph assigned display value given attr. default name attribute set graph edges included edges. value gets used display edge attribute graph's internal edge data frame.","code":""},{"path":"/reference/set_edge_attr_to_display.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_edge_attr_to_display.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_edge_attrs( edge_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # For edge ID values of `1`, # `2`, and `3`, choose to display # the edge `value` attribute (for # the other edges, display nothing) graph <- graph %>% set_edge_attr_to_display( edges = 1:3, attr = value, default = NA) # Show the graph's edge data frame; the # `display` edge attribute will show, for # each row, which edge attribute value to # display when the graph is rendered graph %>% get_edge_df() #> id from to rel display value #> 1 1 2 1 value 2.5 #> 2 2 3 1 value 8.2 #> 3 3 3 2 value 4.2 #> 4 4 4 3 2.4 # This function can be called multiple # times on a graph; after the first time # (i.e., creation of the `display` # attribute), the `default` value won't # be used graph %>% set_edge_attr_to_display( edges = 4, attr = to) %>% set_edge_attr_to_display( edges = c(1, 3), attr = id) %>% get_edge_df() #> id from to rel display value #> 1 1 2 1 id 2.5 #> 2 2 3 1 value 8.2 #> 3 3 3 2 id 4.2 #> 4 4 4 3 to 2.4"},{"path":"/reference/set_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Set edge attribute values — set_edge_attrs","title":"Set edge attribute values — set_edge_attrs","text":"graph object class dgr_graph, set edge attribute values one edges.","code":""},{"path":"/reference/set_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set edge attribute values — set_edge_attrs","text":"","code":"set_edge_attrs(graph, edge_attr, values, from = NULL, to = NULL)"},{"path":"/reference/set_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set edge attribute values — set_edge_attrs","text":"graph graph object class dgr_graph. edge_attr name attribute set. values values set chosen attribute chosen edges. optional vector node IDs edge outgoing filtering list nodes outgoing edges graph. optional vector node IDs edge incoming filtering list nodes incoming edges graph.","code":""},{"path":"/reference/set_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set edge attribute values — set_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set edge attribute values — set_edge_attrs","text":"","code":"# Create a simple graph ndf <- create_node_df( n = 4, type = \"basic\", label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\") graph <- create_graph( nodes_df = ndf, edges_df = edf) # Set attribute `color = \"green\"` # for edges `1`->`4` and `3`->`1` # in the graph graph <- graph %>% set_edge_attrs( edge_attr = color, values = \"green\", from = c(1, 3), to = c(4, 1)) # Set attribute `color = \"blue\"` # for all edges in the graph graph <- graph %>% set_edge_attrs( edge_attr = color, values = \"blue\") # Set attribute `color = \"pink\"` # for all edges in graph outbound # from node with ID value `1` graph <- graph %>% set_edge_attrs( edge_attr = color, values = \"pink\", from = 1) # Set attribute `color = \"black\"` # for all edges in graph inbound # to node with ID `1` graph <- graph %>% set_edge_attrs( edge_attr = color, values = \"black\", to = 1)"},{"path":"/reference/set_edge_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Set edge attributes with an edge selection — set_edge_attrs_ws","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"graph object class dgr_graph edge data frame, set edge attribute properties one edges. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/set_edge_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"","code":"set_edge_attrs_ws(graph, edge_attr, value)"},{"path":"/reference/set_edge_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"graph graph object class dgr_graph. edge_attr name attribute set. value value set chosen attribute edges current selection.","code":""},{"path":"/reference/set_edge_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_edge_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_path(n = 6) # Select specific edges from # the graph and apply the edge # attribute `color = blue` to # those selected edges graph <- graph %>% select_nodes_by_id(nodes = 2:4) %>% trav_out_edge() %>% set_edge_attrs_ws( edge_attr = color, value = \"blue\") # Show the internal edge data # frame to verify that the # edge attribute has been set # for specific edges graph %>% get_edge_df() #> id from to rel color #> 1 1 1 2 #> 2 2 2 3 blue #> 3 3 3 4 blue #> 4 4 4 5 blue #> 5 5 5 6 "},{"path":"/reference/set_graph_directed.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an undirected graph to a directed graph — set_graph_directed","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"Take graph undirected convert directed graph.","code":""},{"path":"/reference/set_graph_directed.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"","code":"set_graph_directed(graph)"},{"path":"/reference/set_graph_directed.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_directed.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_directed.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"","code":"# Create a graph with a # undirected tree graph <- create_graph( directed = FALSE) %>% add_balanced_tree( k = 2, h = 2) # Convert this graph from # undirected to directed graph <- graph %>% set_graph_directed() # Perform a check on whether # graph is directed graph %>% is_graph_directed() #> [1] TRUE"},{"path":"/reference/set_graph_name.html","id":null,"dir":"Reference","previous_headings":"","what":"Set graph name — set_graph_name","title":"Set graph name — set_graph_name","text":"Set name graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_name.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set graph name — set_graph_name","text":"","code":"set_graph_name(graph, name)"},{"path":"/reference/set_graph_name.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set graph name — set_graph_name","text":"graph graph object class dgr_graph. name name set graph.","code":""},{"path":"/reference/set_graph_name.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set graph name — set_graph_name","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_name.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set graph name — set_graph_name","text":"","code":"# Create an empty graph graph <- create_graph() # Provide the new graph with a name graph <- graph %>% set_graph_name( name = \"example_name\")"},{"path":"/reference/set_graph_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Set graph date-time and timezone — set_graph_time","title":"Set graph date-time and timezone — set_graph_time","text":"Set time timezone graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set graph date-time and timezone — set_graph_time","text":"","code":"set_graph_time(graph, time = NULL, tz = NULL)"},{"path":"/reference/set_graph_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set graph date-time and timezone — set_graph_time","text":"graph graph object class dgr_graph. time date-time set graph. tz timezone set graph.","code":""},{"path":"/reference/set_graph_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set graph date-time and timezone — set_graph_time","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_time.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set graph date-time and timezone — set_graph_time","text":"","code":"# Create an empty graph graph <- create_graph() # Provide the new graph with a timestamp (if `tz` # is not supplied, `GMT` is used as the time zone) graph_1 <- graph %>% set_graph_time(time = \"2015-10-25 15:23:00\") # Provide the new graph with a timestamp that is # the current time; the time zone is inferred from # the user's locale graph_2 <- graph %>% set_graph_time() # The time zone can be updated when a timestamp # is present graph_2 <- graph_2 %>% set_graph_time(tz = \"America/Los_Angeles\")"},{"path":"/reference/set_graph_undirected.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a directed graph to an undirected graph — set_graph_undirected","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"Take graph directed convert undirected graph.","code":""},{"path":"/reference/set_graph_undirected.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"","code":"set_graph_undirected(graph)"},{"path":"/reference/set_graph_undirected.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_undirected.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_undirected.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"","code":"# Create a graph with a # directed tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Convert this graph from # directed to undirected graph <- graph %>% set_graph_undirected() # Perform a check on whether # graph is directed graph %>% is_graph_directed() #> [1] FALSE"},{"path":"/reference/set_node_attr_to_display.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the node attribute values to be rendered — set_node_attr_to_display","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"Set node attribute type display node text calling render_graph() function. allows display different types node attribute values per-node basis. Without setting display attribute, rendering graph default printing text label attribute nodes. Setting display node attribute function first time (.e., display column exist graph's internal node data frame) insert attr value nodes specified nodes default value (default) remaining nodes.","code":""},{"path":"/reference/set_node_attr_to_display.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"","code":"set_node_attr_to_display(graph, attr = NULL, nodes = NULL, default = \"label\")"},{"path":"/reference/set_node_attr_to_display.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"graph graph object class dgr_graph. attr name attribute label text node obtained. set NULL, NA values assigned display column chosen nodes. nodes length vector containing one several node ID values (integers) node attributes set display rendered graph. NULL, nodes graph assigned display value given attr. default name attribute set graph nodes included nodes. value gets used display node attribute graph's internal node data frame.","code":""},{"path":"/reference/set_node_attr_to_display.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_attr_to_display.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_node_attrs( node_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # For node ID values of `1`, # `2`, and `3`, choose to display # the node `value` attribute (for # the other nodes, display nothing) graph <- graph %>% set_node_attr_to_display( nodes = 1:3, attr = value, default = NA) # Show the graph's node data frame; the # `display` node attribute will show for # each row, which node attribute value to # display when the graph is rendered graph %>% get_node_df() #> id type label display value #> 1 1 1 value 2.5 #> 2 2 2 value 8.2 #> 3 3 3 value 4.2 #> 4 4 4 2.4 # This function can be called multiple # times on a graph; after the first time # (i.e., creation of the `display` # attribute), the `default` value won't # be used graph %>% set_node_attr_to_display( nodes = 4, attr = label) %>% set_node_attr_to_display( nodes = c(1, 3), attr = id) %>% get_node_df() #> id type label display value #> 1 1 1 id 2.5 #> 2 2 2 value 8.2 #> 3 3 3 id 4.2 #> 4 4 4 label 2.4"},{"path":"/reference/set_node_attr_w_fcn.html","id":null,"dir":"Reference","previous_headings":"","what":"Set node attribute values with a graph function — set_node_attr_w_fcn","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"graph object class dgr_graph node data frame, set node attribute properties nodes graph using one several whole-graph functions.","code":""},{"path":"/reference/set_node_attr_w_fcn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"","code":"set_node_attr_w_fcn(graph, node_attr_fcn, ..., column_name = NULL)"},{"path":"/reference/set_node_attr_w_fcn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"graph graph object class dgr_graph. node_attr_fcn name function use creating column node attribute values. Valid functions : get_alpha_centrality(), get_authority_centrality(), get_betweenness(), get_closeness(), get_cmty_edge_btwns(), get_cmty_fast_greedy(), get_cmty_l_eigenvec(), get_cmty_louvain(), get_cmty_walktrap(), get_degree_distribution(), get_degree_histogram(), get_degree_in(), get_degree_out(), get_degree_total(), get_eccentricity(), get_eigen_centrality(), get_pagerank(), get_s_connected_cmpts(), get_w_connected_cmpts(). ... Arguments values pass named function node_attr_fcn, necessary. column_name option supply column name new node attribute column. NULL column name supplied function used along __A suffix.","code":""},{"path":"/reference/set_node_attr_w_fcn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_attr_w_fcn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 22, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the betweenness values for # each of the graph's nodes as a # node attribute graph_1 <- graph %>% set_node_attr_w_fcn( node_attr_fcn = \"get_betweenness\") # Inspect the graph's internal # node data frame graph_1 %>% get_node_df() #> id type label value betweenness__A #> 1 1 1 4.4 9.333333 #> 2 2 2 4.6 29.000000 #> 3 3 3 5.9 19.166667 #> 4 4 4 6.5 2.666667 #> 5 5 5 4.1 0.500000 #> 6 6 6 3.6 18.000000 #> 7 7 7 5.4 12.000000 #> 8 8 8 5.8 0.000000 #> 9 9 9 4.7 10.333333 #> 10 10 10 5.7 0.000000 # If a specified function takes argument # values, these can be supplied as well graph_2 <- graph %>% set_node_attr_w_fcn( node_attr_fcn = \"get_alpha_centrality\", alpha = 2, exo = 2) # Inspect the graph's internal # node data frame graph_2 %>% get_node_df() #> id type label value alpha_centrality__A #> 1 1 1 4.4 0.0621118 #> 2 2 2 4.6 -0.5341615 #> 3 3 3 5.9 -0.8157350 #> 4 4 4 6.5 -0.6997930 #> 5 5 5 4.1 1.0641822 #> 6 6 6 3.6 -0.8737060 #> 7 7 7 5.4 -0.6832298 #> 8 8 8 5.8 0.9316770 #> 9 9 9 4.7 -0.4679089 #> 10 10 10 5.7 0.3685300 # The new column name can be provided graph_3 <- graph %>% set_node_attr_w_fcn( node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\") # Inspect the graph's internal # node data frame graph_3 %>% get_node_df() #> id type label value pagerank #> 1 1 1 4.4 0.1416 #> 2 2 2 4.6 0.1401 #> 3 3 3 5.9 0.1262 #> 4 4 4 6.5 0.0637 #> 5 5 5 4.1 0.0478 #> 6 6 6 3.6 0.1976 #> 7 7 7 5.4 0.1318 #> 8 8 8 5.8 0.0422 #> 9 9 9 4.7 0.0693 #> 10 10 10 5.7 0.0398 # If `graph_3` is modified by # adding a new node then the column # `pagerank` will have stale data; we # can run the function again and re-use # the existing column name to provide # updated values graph_3 <- graph_3 %>% add_node( from = 1, to = 3) %>% set_node_attr_w_fcn( node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\") # Inspect the graph's internal # node data frame graph_3 %>% get_node_df() #> id type label value pagerank #> 1 1 1 4.4 0.1349 #> 2 2 2 4.6 0.1352 #> 3 3 3 5.9 0.1585 #> 4 4 4 6.5 0.0670 #> 5 5 5 4.1 0.0461 #> 6 6 6 3.6 0.1300 #> 7 7 7 5.4 0.1014 #> 8 8 8 5.8 0.0400 #> 9 9 9 4.7 0.0685 #> 10 10 10 5.7 0.0440 #> 11 11 NA 0.0744"},{"path":"/reference/set_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Set node attribute values — set_node_attrs","title":"Set node attribute values — set_node_attrs","text":"graph object class dgr_graph, set node attribute values one nodes.","code":""},{"path":"/reference/set_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set node attribute values — set_node_attrs","text":"","code":"set_node_attrs(graph, node_attr, values, nodes = NULL)"},{"path":"/reference/set_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set node attribute values — set_node_attrs","text":"graph graph object class dgr_graph. node_attr name attribute set. values values set chosen attribute chosen nodes. nodes optional vector node IDs filtering list nodes present graph.","code":""},{"path":"/reference/set_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set node attribute values — set_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set node attribute values — set_node_attrs","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"basic\", label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\") # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Set attribute `color = \"green\"` for # nodes `1` and `3` using the graph object graph <- graph %>% set_node_attrs( node_attr = color, values = \"green\", nodes = c(1, 3)) # View the graph's node data frame graph %>% get_node_df() #> id type label value color #> 1 1 basic 1 3.5 green #> 2 2 basic 2 2.6 #> 3 3 basic 3 9.4 green #> 4 4 basic 4 2.7 # Set attribute `color = \"blue\"` for # all nodes in the graph graph <- graph %>% set_node_attrs( node_attr = color, values = \"blue\") # Display the graph's ndf graph %>% get_node_df() #> id type label value color #> 1 1 basic 1 3.5 blue #> 2 2 basic 2 2.6 blue #> 3 3 basic 3 9.4 blue #> 4 4 basic 4 2.7 blue"},{"path":"/reference/set_node_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Set node attributes with a node selection — set_node_attrs_ws","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"graph object class dgr_graph node data frame, set node attribute properties nodes present node selection. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/set_node_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"","code":"set_node_attrs_ws(graph, node_attr, value)"},{"path":"/reference/set_node_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"graph graph object class dgr_graph. node_attr name attribute set. value value set chosen attribute nodes current selection.","code":""},{"path":"/reference/set_node_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_path(n = 6) # Select specific nodes from the graph and # apply the node attribute `color = blue` to # those selected nodes graph <- graph %>% select_nodes_by_id( nodes = 1:4) %>% trav_out() %>% set_node_attrs_ws( node_attr = color, value = \"blue\") # Show the internal node data frame to verify # that the node attribute has been set for # specific node graph %>% get_node_df() #> id type label color #> 1 1 1 #> 2 2 2 blue #> 3 3 3 blue #> 4 4 4 blue #> 5 5 5 blue #> 6 6 6 "},{"path":"/reference/set_node_position.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply a layout position to a single node — set_node_position","title":"Apply a layout position to a single node — set_node_position","text":"Apply position information single node. done setting x y attrs node id node label supplied node. rendering graph, nodes attribute values set x y fixed positions graph canvas.","code":""},{"path":"/reference/set_node_position.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply a layout position to a single node — set_node_position","text":"","code":"set_node_position(graph, node, x, y, use_labels = FALSE)"},{"path":"/reference/set_node_position.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply a layout position to a single node — set_node_position","text":"graph graph object class dgr_graph. node single-length vector containing either node ID value (integer) node label (character) position information applied. x x coordinate set node. y y coordinate set node. use_labels option use node label value node. Note possible nodes distinct label values set none exist NA value.","code":""},{"path":"/reference/set_node_position.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Apply a layout position to a single node — set_node_position","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_position.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply a layout position to a single node — set_node_position","text":"","code":"# Create a simple graph with 4 nodes graph <- create_graph() %>% add_node(label = \"one\") %>% add_node(label = \"two\") %>% add_node(label = \"three\") %>% add_node(label = \"four\") # Add position information to each of # the graph's nodes graph <- graph %>% set_node_position( node = 1, x = 1, y = 1) %>% set_node_position( node = 2, x = 2, y = 2) %>% set_node_position( node = 3, x = 3, y = 3) %>% set_node_position( node = 4, x = 4, y = 4) # View the graph's node data frame to # verify that the `x` and `y` node # attributes are available and set to # the values provided graph %>% get_node_df() #> id type label x y #> 1 1 one 1 1 #> 2 2 two 2 2 #> 3 3 three 3 3 #> 4 4 four 4 4 # The same function can modify the data # in the `x` and `y` attributes graph <- graph %>% set_node_position( node = 1, x = 1, y = 4) %>% set_node_position( node = 2, x = 3, y = 3) %>% set_node_position( node = 3, x = 3, y = 2) %>% set_node_position( node = 4, x = 4, y = 1) # View the graph's node data frame graph %>% get_node_df() #> id type label x y #> 1 1 one 1 4 #> 2 2 two 3 3 #> 3 3 three 3 2 #> 4 4 four 4 1 # Position changes can also be made by # supplying a node `label` value (and setting # `use_labels` to TRUE). For this to work, # all `label` values in the graph's ndf must # be unique and non-NA graph <- graph %>% set_node_position( node = \"one\", x = 1, y = 1, use_labels = TRUE) %>% set_node_position( node = \"two\", x = 2, y = 2, use_labels = TRUE) # View the graph's node data frame graph %>% get_node_df() #> id type label x y #> 1 1 one 1 1 #> 2 2 two 2 2 #> 3 3 three 3 2 #> 4 4 four 4 1"},{"path":"/reference/to_igraph.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a DiagrammeR graph to an igraph one — to_igraph","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"Convert DiagrammeR graph igraph graph object.","code":""},{"path":"/reference/to_igraph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"","code":"to_igraph(graph)"},{"path":"/reference/to_igraph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/to_igraph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"igraph object.","code":""},{"path":"/reference/to_igraph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 36, m = 50, set_seed = 23) # Confirm that `graph` is a # DiagrammeR graph by getting # the object's class class(graph) #> [1] \"dgr_graph\" # Convert the DiagrammeR graph # to an igraph object ig_graph <- to_igraph(graph) # Get the class of the converted # graph, just to be certain class(ig_graph) #> [1] \"igraph\" # Get a summary of the igraph # graph object summary(ig_graph) #> IGRAPH 267c86e DN-B 36 50 -- #> + attr: name (v/c), type (v/c), label (v/c), rel (e/c)"},{"path":"/reference/transform_to_complement_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a complement of a graph — transform_to_complement_graph","title":"Create a complement of a graph — transform_to_complement_graph","text":"Create complement graph contains edges present input graph. important nodes edge attributes input graph's edges lost. Node attributes retained, since affected transformation.","code":""},{"path":"/reference/transform_to_complement_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a complement of a graph — transform_to_complement_graph","text":"","code":"transform_to_complement_graph(graph, loops = FALSE)"},{"path":"/reference/transform_to_complement_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a complement of a graph — transform_to_complement_graph","text":"graph graph object class dgr_graph. loops option whether loops generated complement graph.","code":""},{"path":"/reference/transform_to_complement_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a complement of a graph — transform_to_complement_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_complement_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a complement of a graph — transform_to_complement_graph","text":"","code":"# Create a simple graph # with a single cycle graph <- create_graph() %>% add_cycle(n = 4) # Get the graph's edge # data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 4 1 # Create the complement # of the graph graph_c <- graph %>% transform_to_complement_graph() # Get the edge data frame # for the complement graph graph_c %>% get_edge_df() #> id from to rel #> 1 1 1 4 #> 2 2 1 3 #> 3 3 2 4 #> 4 4 2 1 #> 5 5 3 2 #> 6 6 3 1 #> 7 7 4 3 #> 8 8 4 2 "},{"path":"/reference/transform_to_min_spanning_tree.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"Get minimum spanning tree subgraph connected graph class dgr_graph.","code":""},{"path":"/reference/transform_to_min_spanning_tree.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"","code":"transform_to_min_spanning_tree(graph)"},{"path":"/reference/transform_to_min_spanning_tree.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_min_spanning_tree.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_min_spanning_tree.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Obtain Jaccard similarity # values for each pair of # nodes as a square matrix j_sim_matrix <- graph %>% get_jaccard_similarity() # Create a weighted, undirected # graph from the resultant matrix # (effectively treating that # matrix as an adjacency matrix) graph <- j_sim_matrix %>% from_adj_matrix(weighted = TRUE) # The graph in this case is a fully connected graph # with loops, where jaccard similarity values are # assigned as edge weights (edge attribute `weight`); # The minimum spanning tree for this graph is the # connected subgraph where the edges retained have # the lowest similarity values possible min_spanning_tree_graph <- graph %>% transform_to_min_spanning_tree() %>% copy_edge_attrs( edge_attr_from = weight, edge_attr_to = label) %>% set_edge_attrs( edge_attr = fontname, values = \"Helvetica\") %>% set_edge_attrs( edge_attr = color, values = \"gray85\") %>% rescale_edge_attrs( edge_attr_from = weight, to_lower_bound = 0.5, to_upper_bound = 4.0, edge_attr_to = penwidth)"},{"path":"/reference/transform_to_subgraph_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"Create subgraph based selection nodes edges stored graph object. function makes use active selection nodes edges (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections edges can performed using following edge selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections nodes edges can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until(), trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/transform_to_subgraph_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"","code":"transform_to_subgraph_ws(graph)"},{"path":"/reference/transform_to_subgraph_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_subgraph_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_subgraph_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 6, value = c(3.5, 2.6, 9.4, 2.7, 5.2, 2.1)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 4, 5, 2, 6, 2), to = c(2, 4, 1, 3, 5, 5, 4)) # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Create a selection of nodes, this selects # nodes `1`, `3`, and `5` graph <- graph %>% select_nodes( conditions = value > 3) # Create a subgraph based on the selection subgraph <- graph %>% transform_to_subgraph_ws() # Display the graph's node data frame subgraph %>% get_node_df() #> id type label value #> 1 1 3.5 #> 2 3 9.4 #> 3 5 5.2 # Display the graph's edge data frame subgraph %>% get_edge_df() #> id from to rel #> 1 4 5 3 # Create a selection of edges, this selects # edges `1`, `2` graph <- graph %>% clear_selection() %>% select_edges( edges = c(1,2)) # Create a subgraph based on the selection subgraph <- graph %>% transform_to_subgraph_ws() # Display the graph's node data frame subgraph %>% get_node_df() #> id type label value #> 1 1 3.5 #> 2 2 2.6 #> 3 4 2.7 # Display the graph's edge data frame subgraph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 4 "},{"path":"/reference/trav_both.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"graph object class dgr_graph move one nodes present selection nodes connected edges, replacing current nodes selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_both.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"","code":"trav_both( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\", add_to_selection = FALSE )"},{"path":"/reference/trav_both.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed nodes. values extant nodes traversed replaced. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg node attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median. add_to_selection option either add traversed nodes active selection nodes (TRUE) switch active selection entirely traversed nodes (FALSE, default case).","code":""},{"path":"/reference/trav_both.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_both.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from node `3` # to adjacent nodes with no conditions on # the nodes traversed to graph %>% select_nodes_by_id(nodes = 3) %>% trav_both() %>% get_selection() #> [1] 1 5 # Traverse from node `2` to any adjacent # nodes, filtering to those nodes that have # numeric values less than `8.0` for # the `values` node attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_both( conditions = values < 8.0) %>% get_selection() #> [1] 4 5 # Traverse from node `5` to any adjacent # nodes, filtering to those nodes that # have a `type` attribute of `b` graph %>% select_nodes_by_id(nodes = 5) %>% trav_both( conditions = type == \"b\") %>% get_selection() #> [1] 3 # Traverse from node `2` to any adjacent # nodes, and use multiple conditions for the # traversal graph %>% select_nodes_by_id(nodes = 2) %>% trav_both( conditions = type == \"a\" & values > 8.0) %>% get_selection() #> [1] 1 # Traverse from node `2` to any adjacent # nodes, and use multiple conditions with # a single-length vector graph %>% select_nodes_by_id(nodes = 2) %>% trav_both( conditions = type == \"a\" | values > 8.0) %>% get_selection() #> [1] 1 # Traverse from node `2` to any adjacent # nodes, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_both( conditions = grepl(\"..d\", label)) %>% get_selection() #> [1] 1 5 # Create another simple graph to demonstrate # copying of node attribute values to traversed # nodes graph <- create_graph() %>% add_path(n = 5) %>% select_nodes_by_id(nodes = c(2, 4)) %>% set_node_attrs_ws( node_attr = value, value = 5) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 1 NA #> 2 2 2 5 #> 3 3 3 NA #> 4 4 4 5 #> 5 5 5 NA # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 4 5 # Perform a traversal from the inner nodes # (`2` and `4`) to their adjacent nodes (`1`, # `3`, and `5`) while also applying the node # attribute `value` to target nodes; node `3` # will obtain a `value` of 10 since a traversal # to `3` will occur from `2` and `4` (and # multiple values passed will be summed) graph <- graph %>% trav_both( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data frame # after this change graph %>% get_node_df() #> id type label value #> 1 1 1 5 #> 2 3 3 10 #> 3 5 5 5 #> 4 2 2 5 #> 5 4 4 5"},{"path":"/reference/trav_both_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"graph object class dgr_graph move adjacent edges selection one selected nodes, thereby creating selection edges. optional filter edge attribute can limit set edges traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection edges selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_both_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"","code":"trav_both_edge( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\" )"},{"path":"/reference/trav_both_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed edges. edge attribute already exists, values merged traversed edges; otherwise, new edge attribute created. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different edge attribute name. attribute name provided copy_attrs_as exist graph's edf, new edge attribute created chosen name. agg node attribute provided copy_attrs_from, aggregation function required since may cases multiple node attribute values passed onto traversed edge(s). pass single value, following aggregation functions can used: sum, min, max, mean, median.","code":""},{"path":"/reference/trav_both_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_both_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df) # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from nodes to # adjacent edges with no conditions on the # nodes traversed to graph %>% select_nodes_by_id(nodes = 3) %>% trav_both_edge() %>% get_selection() #> [1] 2 5 # Traverse from node `2` to any adjacent # edges, filtering to those edges that have # NA values for the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = is.na(rel)) %>% get_selection() #> [1] 1 # Traverse from node `2` to any adjacent # edges, filtering to those edges that have # numeric values greater than `6.5` for # the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = values > 6.5) %>% get_selection() #> [1] 2 # Traverse from node `5` to any adjacent # edges, filtering to those edges that # have values equal to `C` for the `rel` # edge attribute graph %>% select_nodes_by_id(nodes = 5) %>% trav_both_edge( conditions = rel == \"C\") %>% get_selection() #> [1] 4 # Traverse from node `2` to any adjacent # edges, filtering to those edges that # have values in the set `B` and `C` for # the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = rel %in% c(\"B\", \"C\")) %>% get_selection() #> [1] 3 4 # Traverse from node `2` to any adjacent # edges, and use multiple conditions for the # traversal graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = rel %in% c(\"B\", \"C\") & values > 4.0) %>% get_selection() #> [1] 3 4 # Traverse from node `2` to any adjacent # edges, and use multiple conditions with # a single-length vector graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = rel %in% c(\"B\", \"C\") | values > 4.0) %>% get_selection() #> [1] 1 3 4 # Traverse from node `2` to any adjacent # edges, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = grepl(\"B|C\", rel)) %>% get_selection() #> [1] 3 4 # Create another simple graph to demonstrate # copying of node attribute values to traversed # edges graph <- create_graph() %>% add_path(n = 4) %>% select_nodes_by_id(nodes = 2:3) %>% set_node_attrs_ws( node_attr = value, value = 5) # Show the graph's internal edge data frame graph %>%get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 1 NA #> 2 2 2 5 #> 3 3 3 5 #> 4 4 4 NA # Perform a traversal from the nodes to # the adjacent edges while also applying # the node attribute `value` to the edges (in # this case summing the `value` of 5 from # all contributing nodes adding as an edge # attribute) graph <- graph %>% trav_both_edge( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal edge data frame # after this change graph %>% get_edge_df() #> id from to rel value #> 1 1 1 2 5 #> 2 2 2 3 10 #> 3 3 3 4 5"},{"path":"/reference/trav_in.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"graph object class dgr_graph move along inward edges one nodes present selection connected nodes, replacing current nodes selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_in.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"","code":"trav_in( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\", add_to_selection = FALSE )"},{"path":"/reference/trav_in.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from providing node attribute name copy node attribute values traversed nodes. values extant nodes traversed replaced. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg node attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median. add_to_selection option either add traversed nodes active selection nodes (TRUE) switch active selection entirely traversed nodes (FALSE, default case).","code":""},{"path":"/reference/trav_in.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_in.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from node `4` to # inward adjacent edges with no conditions # on the nodes traversed to graph %>% select_nodes_by_id(nodes = 4) %>% trav_in() %>% get_selection() #> [1] 2 # Traverse from node `5` to inbound-facing # nodes, filtering to those nodes that have # numeric values greater than `5.0` for # the `values` node attribute graph %>% select_nodes_by_id(nodes = 4) %>% trav_in( conditions = values > 5.0) %>% get_selection() #> [1] 2 # Traverse from node `5` to any inbound # nodes, filtering to those nodes that # have a `type` attribute of `b` graph %>% select_nodes_by_id(nodes = 5) %>% trav_in( conditions = type == \"b\") %>% get_selection() #> [1] 3 # Traverse from node `5` to any inbound # nodes, filtering to those nodes that # have a degree of `2` graph %>% { node_degrees <- get_node_info(.) %>% dplyr::select(id, deg) join_node_attrs(., node_degrees) } %>% select_nodes_by_id(nodes = 5) %>% trav_in( conditions = deg == 2) %>% get_selection() #> [1] 3 # Traverse from node `5` to any inbound # nodes, and use multiple conditions for the # traversal graph %>% select_nodes_by_id(nodes = 5) %>% trav_in( conditions = type == \"a\" & values > 6.0) %>% get_selection() #> [1] 2 # Traverse from node `5` to any inbound # nodes, and use multiple conditions with # a single-length vector graph %>% select_nodes_by_id(nodes = 5) %>% trav_in( conditions = type == \"b\" | values > 6.0) %>% get_selection() #> [1] 2 3 # Traverse from node `5` to any inbound # nodes, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_in( conditions = grepl(\"^i.*\", label)) %>% get_selection() #> [1] 2 # Create another simple graph to demonstrate # copying of node attribute values to traversed # nodes graph <- create_graph() %>% add_node() %>% select_nodes() %>% add_n_nodes_ws( n = 2, direction = \"from\") %>% clear_selection() %>% select_nodes_by_id(nodes = 2:3) %>% set_node_attrs_ws( node_attr = value, value = 5) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 NA #> 2 2 5 #> 3 3 5 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 1 3 # Perform a traversal from the outer nodes # (`2` and `3`) to the central node (`1`) while # also applying the node attribute `value` to # node `1` (summing the `value` of 5 from # both nodes before applying the value to the # target node) graph <- graph %>% trav_in( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data frame # after this change graph %>% get_node_df() #> id type label value #> 1 1 10 #> 2 2 5 #> 3 3 5"},{"path":"/reference/trav_in_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"graph object class dgr_graph move incoming edges selection one selected nodes, thereby creating selection edges. optional filter edge attribute can limit set edges traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection edges selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_in_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"","code":"trav_in_edge( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL )"},{"path":"/reference/trav_in_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed edges. edge attribute already exists, values merged traversed edges; otherwise, new edge attribute created. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different edge attribute name. attribute name provided copy_attrs_as exist graph's edf, new edge attribute created chosen name.","code":""},{"path":"/reference/trav_in_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_in_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID # values representing the graph edges # (with `from` and `to` columns), and, # a set of numeric values df <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Join the data frame to the graph's # internal edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df) # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from # nodes to inbound edges with no # conditions on the nodes # traversed to graph %>% select_nodes_by_id(nodes = 2) %>% trav_in_edge() %>% get_selection() #> [1] 1 # Traverse from node `2` to any # inbound edges, filtering to # those edges that have NA values # for the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_in_edge( conditions = is.na(rel)) %>% get_selection() #> [1] 1 # Traverse from node `2` to any # inbound edges, filtering to those # edges that do not have NA values # for the `rel` edge attribute # (since there are no allowed # traversals, the selection of node # `2` is retained) graph %>% select_nodes_by_id(nodes = 2) %>% trav_in_edge( conditions = !is.na(rel)) %>% get_selection() #> [1] 2 # Traverse from node `5` to any # inbound edges, filtering to those # edges that have numeric values # greater than `5.5` for the `rel` # edge attribute graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = values > 5.5) %>% get_selection() #> [1] 4 # Traverse from node `5` to any # inbound edges, filtering to those # edges that have values equal to # `D` for the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = rel == \"D\") %>% get_selection() #> [1] 5 # Traverse from node `5` to any # inbound edges, filtering to those # edges that have values in the set # `C` and `D` for the `rel` edge # attribute graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = rel %in% c(\"C\", \"D\")) %>% get_selection() #> [1] 4 5 # Traverse from node `5` to any # inbound edges, and use multiple # conditions for the traversal graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = rel %in% c(\"C\", \"D\") & values > 5.5) %>% get_selection() #> [1] 4 # Traverse from node `5` to any # inbound edges, and use multiple # conditions with a single-length # vector graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = rel %in% c(\"D\", \"E\") | values > 5.5) %>% get_selection() #> [1] 4 5 # Traverse from node `5` to any # inbound edges, and use a regular # expression as a filtering condition graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = grepl(\"C|D\", rel)) %>% get_selection() #> [1] 4 5 # Show the graph's internal ndf graph %>% get_node_df() #> id type label #> 1 1 a asd #> 2 2 a iekd #> 3 3 b idj #> 4 4 b edl #> 5 5 b ohd # Show the graph's internal edf graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a traversal from all # nodes to their incoming edges and, # while doing so, copy the `label` # node attribute to any of the nodes' # incoming edges graph <- graph %>% select_nodes() %>% trav_in_edge( copy_attrs_from = label) # Show the graph's internal edge # data frame after this change graph %>% get_edge_df() #> id from to rel label values #> 1 1 1 2 iekd 6.00 #> 2 2 1 3 A idj 6.11 #> 3 3 2 4 B edl 4.72 #> 4 4 2 5 C ohd 6.02 #> 5 5 3 5 D ohd 5.05"},{"path":"/reference/trav_in_node.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"graph object class dgr_graph active selection edges move edge direction connected nodes, replacing current edges selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection edges. traversal, depending traversal conditions, either selection nodes selection . Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/trav_in_node.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"","code":"trav_in_node( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\" )"},{"path":"/reference/trav_in_node.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing edge attribute name copy edge attribute values traversed nodes. edge attribute already exists, values merged traversed nodes; otherwise, new node attribute created. copy_attrs_as edge attribute name provided copy_attrs_from, option allow copied attribute values written different node attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg edge attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median.","code":""},{"path":"/reference/trav_in_node.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_in_node.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from the # edge `1`->`3` to the attached node # in the direction of the edge; here, no # conditions are placed on the nodes # traversed to graph %>% select_edges( from = 1, to = 3) %>% trav_in_node() %>% get_selection() #> [1] 3 # Traverse from edges `2`->`5` and # `3`->`5` to the attached node along # the direction of the edge; both # traversals lead to the same node graph %>% select_edges( from = 2, to = 5) %>% select_edges( from = 3, to = 5) %>% trav_in_node() %>% get_selection() #> [1] 5 # Traverse from the edge `1`->`3` # to the attached node where the edge # is incoming, this time filtering # numeric values greater than `5.0` for # the `values` node attribute graph %>% select_edges( from = 1, to = 3) %>% trav_in_node( conditions = values > 5.0) %>% get_selection() #> [1] 3 # Traverse from the edge `1`->`3` # to the attached node where the edge # is incoming, this time filtering # numeric values less than `5.0` for # the `values` node attribute (the # condition is not met so the original # selection of edge `1` -> `3` remains) graph %>% select_edges( from = 1, to = 3) %>% trav_in_node( conditions = values < 5.0) %>% get_selection() #> [1] 2 # Traverse from the edge `1`->`2` to # the node `2` using multiple conditions # with a single-length vector graph %>% select_edges( from = 1, to = 2) %>% trav_in_node( conditions = grepl(\".*d$\", label) | values < 6.0) %>% get_selection() #> [1] 2 # Create another simple graph to demonstrate # copying of edge attribute values to traversed # nodes graph <- create_graph() %>% add_node() %>% select_nodes() %>% add_n_nodes_ws( n = 2, direction = \"to\") %>% clear_selection() %>% select_nodes_by_id(nodes = 2) %>% set_node_attrs_ws( node_attr = value, value = 8) %>% clear_selection() %>% select_edges_by_edge_id(edges = 1) %>% set_edge_attrs_ws( edge_attr = value, value = 5) %>% clear_selection() %>% select_edges_by_edge_id(edges = 2) %>% set_edge_attrs_ws( edge_attr = value, value = 5) %>% clear_selection() %>% select_edges() # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel value #> 1 1 2 1 5 #> 2 2 3 1 5 # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 NA #> 2 2 8 #> 3 3 NA # Perform a traversal from the edges to # the central node (`1`) while also applying # the edge attribute `value` to the node (in # this case summing the `value` of 5 from # both edges before adding as a node attribute) graph <- graph %>% trav_in_node( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data frame # after this change graph %>% get_node_df() #> id type label value #> 1 1 10 #> 2 2 8 #> 3 3 NA"},{"path":"/reference/trav_in_until.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"graph object class dgr_graph, move along inward edges one nodes present selection connected nodes, replacing current nodes selection nodes traversed reaching nodes satisfy one conditions. traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_in_until.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"","code":"trav_in_until( graph, conditions, max_steps = 30, exclude_unmatched = TRUE, add_to_selection = FALSE )"},{"path":"/reference/trav_in_until.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"graph graph object class dgr_graph. conditions option use stopping condition traversal. condition met traversal (.e., node(s) traversed match condition), traversals terminate nodes. Otherwise, traversals continue terminate number steps provided max_steps reached. max_steps maximum number trav_in() steps (.e., node--node traversals inward direction) allow stopping. exclude_unmatched TRUE (default value) nodes satisfying conditions provided conditions ending selection excluded. add_to_selection TRUE every node traversed part final selection nodes. FALSE (default value) nodes finally traversed part final node selection.","code":""},{"path":"/reference/trav_in_until.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_in_until.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"","code":"# Create a path graph and add # values of 1 to 10 across the # nodes from beginning to end; # select the last path node graph <- create_graph() %>% add_path( n = 10, node_data = node_data( value = 1:10)) %>% select_nodes_by_id( nodes = 10) # Traverse inward, node-by-node # until stopping at a node where # the `value` attribute is 1 graph <- graph %>% trav_in_until( conditions = value == 1) # Get the graph's node selection graph %>% get_selection() #> [1] 1 # Create two cycles in a graph and # add values of 1 to 6 to the # first cycle, and values 7 to # 12 in the second; select nodes # `6` and `12` graph <- create_graph() %>% add_cycle( n = 6, node_data = node_data( value = 1:6)) %>% add_cycle( n = 6, node_data = node_data( value = 7:12)) %>% select_nodes_by_id( nodes = c(6, 12)) # Traverse inward, node-by-node # from `6` and `12` until stopping # at the first nodes where the # `value` attribute is 1, 2, or 10; # specify that we should only # keep the finally traversed to # nodes that satisfy the conditions graph <- graph %>% trav_in_until( conditions = value %in% c(1, 2, 10), exclude_unmatched = TRUE) # Get the graph's node selection graph %>% get_selection() #> [1] 2 10"},{"path":"/reference/trav_out.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"graph object class dgr_graph move along outward edges one nodes present selection connected nodes, replacing current nodes selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_out.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"","code":"trav_out( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\", add_to_selection = FALSE )"},{"path":"/reference/trav_out.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed nodes. values extant nodes traversed replaced. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg node attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median. add_to_selection option either add traversed nodes active selection nodes (TRUE) switch active selection entirely traversed nodes (FALSE, default case).","code":""},{"path":"/reference/trav_out.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_out.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from node `3` # to outward adjacent nodes with no conditions # on the nodes traversed to graph %>% select_nodes_by_id(nodes = 3) %>% trav_out() %>% get_selection() #> [1] 5 # Traverse from node `1` to outbound # nodes, filtering to those nodes that have # numeric values greater than `7.0` for # the `values` node attribute graph %>% select_nodes_by_id(nodes = 1) %>% trav_out( conditions = values > 7.0) %>% get_selection() #> [1] 2 # Traverse from node `1` to any outbound # nodes, filtering to those nodes that # have a `type` attribute of `b` graph %>% select_nodes_by_id(nodes = 1) %>% trav_out( conditions = type == \"b\") %>% get_selection() #> [1] 3 # Traverse from node `2` to any outbound # nodes, filtering to those nodes that # have a degree of `1` graph %>% { node_degrees <- get_node_info(.) %>% dplyr::select(id, deg) join_node_attrs( graph = ., df = node_degrees) } %>% select_nodes_by_id(nodes = 2) %>% trav_out( conditions = deg == 1) %>% get_selection() #> [1] 4 # Traverse from node `2` to any outbound # nodes, and use multiple conditions for # the traversal graph %>% select_nodes_by_id(nodes = 2) %>% trav_out( conditions = type == \"a\" & values > 8.0) %>% get_selection() #> [1] 2 # Traverse from node `2` to any # outbound nodes, and use multiple # conditions with a single-length vector graph %>% select_nodes_by_id(nodes = 2) %>% trav_out( conditions = type == \"b\" | values > 8.0) %>% get_selection() #> [1] 4 5 # Traverse from node `2` to any outbound # nodes, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_out( conditions = grepl(\"..d\", label)) %>% get_selection() #> [1] 5 # Create another simple graph to demonstrate # copying of node attribute values to traversed # nodes graph <- create_graph() %>% add_node() %>% select_nodes() %>% add_n_nodes_ws( n = 2, direction = \"to\") %>% clear_selection() %>% select_nodes_by_id(nodes = 2:3) %>% set_node_attrs_ws( node_attr = value, value = 5) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 NA #> 2 2 5 #> 3 3 5 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 2 1 #> 2 2 3 1 # Perform a traversal from the outer nodes # (`2` and `3`) to the central node (`1`) while # also applying the node attribute `value` to # node `1` (summing the `value` of 5 from # both nodes before applying that value to the # target node) graph <- graph %>% trav_out( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data # frame after this change graph %>% get_node_df() #> id type label value #> 1 1 10 #> 2 2 5 #> 3 3 5"},{"path":"/reference/trav_out_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"graph object class dgr_graph move outgoing edges selection one selected nodes, thereby creating selection edges. optional filter edge attribute can limit set edges traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection edges selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_out_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"","code":"trav_out_edge( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL )"},{"path":"/reference/trav_out_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed edges. edge attribute already exists, values merged traversed edges; otherwise, new edge attribute created. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different edge attribute name. attribute name provided copy_attrs_as exist graph's edf, new edge attribute created chosen name.","code":""},{"path":"/reference/trav_out_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_out_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) %>% set_node_attrs( node_attr = values, values = c(2.3, 4.7, 9.4, 8.3, 6.3)) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs( df = df) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 2.3 #> 2 2 a iekd 4.7 #> 3 3 b idj 9.4 #> 4 4 b edl 8.3 #> 5 5 b ohd 6.3 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from nodes to # outbound edges with no conditions on the # nodes traversed to graph %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge() %>% get_selection() #> [1] 1 2 # Traverse from node `1` to any outbound # edges, filtering to those edges that have # NA values for the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge( conditions = is.na(rel)) %>% get_selection() #> [1] 1 # Traverse from node `3` to any outbound # edges, filtering to those edges that have # numeric values greater than `5.0` for # the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 3) %>% trav_out_edge( conditions = values > 5.0) %>% get_selection() #> [1] 5 # Traverse from node `1` to any outbound # edges, filtering to those edges that # have values equal to `A` for the `rel` # edge attribute graph %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge( conditions = rel == \"A\") %>% get_selection() #> [1] 2 # Traverse from node `2` to any outbound # edges, filtering to those edges that # have values in the set `B` and `C` for # the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_out_edge( conditions = rel %in% c(\"B\", \"C\")) %>% get_selection() #> [1] 3 4 # Traverse from node `2` to any # outbound edges, and use multiple # conditions for the traversal graph %>% select_nodes_by_id(nodes = 2) %>% trav_out_edge( conditions = rel %in% c(\"B\", \"C\") & values >= 5.0) %>% get_selection() #> [1] 4 # Traverse from node `2` to any # outbound edges, and use multiple # conditions graph %>% select_nodes_by_id(nodes = 2) %>% trav_out_edge( conditions = rel %in% c(\"B\", \"C\") | values > 6.0) %>% get_selection() #> [1] 3 4 # Traverse from node `2` to any outbound # edges, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_out_edge( conditions = grepl(\"B|C\", rel)) %>% get_selection() #> [1] 3 4 # Perform a traversal from all nodes to # their outgoing edges and, while doing # so, copy the `label` node attribute # to any of the nodes' incoming edges graph <- graph %>% select_nodes() %>% trav_out_edge( copy_attrs_from = label) # Show the graph's internal edge # data frame after this change graph %>% get_edge_df() #> id from to rel label values #> 1 1 1 2 asd 6.00 #> 2 1 2 3 A asd 6.11 #> 3 2 3 4 B iekd 4.72 #> 4 2 4 5 C iekd 6.02 #> 5 3 5 5 D idj 5.05"},{"path":"/reference/trav_out_node.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"graph object class dgr_graph active selection edges move opposite edge direction connected nodes, replacing current edge selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection edges. traversal, depending traversal conditions, either selection nodes selection . Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/trav_out_node.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"","code":"trav_out_node( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\" )"},{"path":"/reference/trav_out_node.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing edge attribute name copy edge attribute values traversed nodes. edge attribute already exists, values merged traversed nodes; otherwise, new node attribute created. copy_attrs_as edge attribute name provided copy_attrs_from, option allow copied attribute values written different node attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg edge attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median.","code":""},{"path":"/reference/trav_out_node.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_out_node.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from the # edge `1`->`3` to the attached node # in the direction of the edge; here, no # conditions are placed on the nodes # traversed to graph %>% select_edges( from = 1, to = 3) %>% trav_out_node() %>% get_selection() #> [1] 1 # Traverse from edges `2`->`5` and # `3`->`5` to the attached node along # the direction of the edge; here, the # traversals lead to different nodes graph %>% select_edges( from = 2, to = 5) %>% select_edges( from = 3, to = 5) %>% trav_out_node() %>% get_selection() #> [1] 2 3 # Traverse from the edge `1`->`3` # to the attached node where the edge # is outgoing, this time filtering # numeric values greater than `7.0` for # the `values` node attribute graph %>% select_edges( from = 1, to = 3) %>% trav_out_node( conditions = values > 7.0) %>% get_selection() #> [1] 1 # Traverse from the edge `1`->`3` # to the attached node where the edge # is outgoing, this time filtering # numeric values less than `7.0` for # the `values` node attribute (the # condition is not met so the original # selection of edge `1`->`3` remains) graph %>% select_edges( from = 1, to = 3) %>% trav_out_node( conditions = values < 7.0) %>% get_selection() #> [1] 2 # Traverse from the edge `1`->`2` # to node `2`, using multiple conditions graph %>% select_edges( from = 1, to = 2) %>% trav_out_node( conditions = grepl(\".*d$\", label) | values < 6.0) %>% get_selection() #> [1] 1 # Create another simple graph to demonstrate # copying of edge attribute values to traversed # nodes graph <- create_graph() %>% add_node() %>% select_nodes() %>% add_n_nodes_ws( n = 2, direction = \"from\") %>% clear_selection() %>% select_nodes_by_id(nodes = 2) %>% set_node_attrs_ws( node_attr = value, value = 8) %>% clear_selection() %>% select_edges_by_edge_id(edges = 1) %>% set_edge_attrs_ws( edge_attr = value, value = 5) %>% clear_selection() %>% select_edges_by_edge_id(edges = 2) %>% set_edge_attrs_ws( edge_attr = value, value = 5) %>% clear_selection() %>% select_edges() # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel value #> 1 1 1 2 5 #> 2 2 1 3 5 # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 NA #> 2 2 8 #> 3 3 NA # Perform a traversal from the edges to # the central node (`1`) while also applying # the edge attribute `value` to the node (in # this case summing the `value` of 5 from # both edges before adding as a node attribute) graph <- graph %>% trav_out_node( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data frame # after this change graph %>% get_node_df() #> id type label value #> 1 1 10 #> 2 2 8 #> 3 3 NA"},{"path":"/reference/trav_out_until.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"graph object class dgr_graph, move along outward edges one nodes present selection connected nodes, replacing current nodes selection nodes traversed reaching nodes satisfy one conditions. traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_out_until.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"","code":"trav_out_until( graph, conditions, max_steps = 30, exclude_unmatched = TRUE, add_to_selection = FALSE )"},{"path":"/reference/trav_out_until.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"graph graph object class dgr_graph. conditions option use stopping condition traversal. condition met traversal (.e., node(s) traversed match condition), traversals terminate nodes. Otherwise, traversals continue terminate number steps provided max_steps reached. max_steps maximum number trav_out() steps (.e., node--node traversals outward direction) allow stopping. exclude_unmatched TRUE (default value) nodes satisfying conditions provided conditions ending selection excluded. add_to_selection TRUE every node traversed part final selection nodes. FALSE (default value) nodes finally traversed part final node selection.","code":""},{"path":"/reference/trav_out_until.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_out_until.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"","code":"# Create a path graph and add # values of 1 to 10 across the # nodes from beginning to end; # select the first path node graph <- create_graph() %>% add_path( n = 10, node_data = node_data( value = 1:10)) %>% select_nodes_by_id( nodes = 1) # Traverse outward, node-by-node # until stopping at a node where # the `value` attribute is 8 graph <- graph %>% trav_out_until( conditions = value == 8) # Get the graph's node selection graph %>% get_selection() #> [1] 8 # Create two cycles in graph and # add values of 1 to 6 to the # first cycle, and values 7 to # 12 in the second; select nodes # `1` and `7` graph <- create_graph() %>% add_cycle( n = 6, node_data = node_data( value = 1:6)) %>% add_cycle( n = 6, node_data = node_data( value = 7:12)) %>% select_nodes_by_id( nodes = c(1, 7)) # Traverse outward, node-by-node # from `1` and `7` until stopping # at the first nodes where the # `value` attribute is 5, 6, or 15; # specify that we should only # keep the finally traversed to # nodes that satisfy the conditions graph <- graph %>% trav_out_until( conditions = value %in% c(5, 6, 9), exclude_unmatched = TRUE) # Get the graph's node selection graph %>% get_selection() #> [1] 5 9"},{"path":"/reference/trav_reverse_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse to any reverse edges — trav_reverse_edge","title":"Traverse to any reverse edges — trav_reverse_edge","text":"active selection edges graph object class dgr_graph, traverse available reverse edges nodes common selected edges. instance, active selection edge 1->2 also (selected) edge 2->1, function can either switch selection 2->1, , incorporate edges active selection edges. traversal function makes use active selection edges. traversal, depending traversal conditions, either selection edges selection . Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/trav_reverse_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse to any reverse edges — trav_reverse_edge","text":"","code":"trav_reverse_edge(graph, add_to_selection = FALSE)"},{"path":"/reference/trav_reverse_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse to any reverse edges — trav_reverse_edge","text":"graph graph object class dgr_graph. add_to_selection option either add reverse edges active selection edges (TRUE) switch active selection entirely reverse edges (FALSE, default case).","code":""},{"path":"/reference/trav_reverse_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse to any reverse edges — trav_reverse_edge","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_reverse_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse to any reverse edges — trav_reverse_edge","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"basic\", label = TRUE) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 4, 2, 3, 3), to = c(4, 1, 3, 2, 1)) # Create a graph with the # ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Explicitly select the edges # `1`->`4` and `2`->`3` graph <- graph %>% select_edges( from = 1, to = 4) %>% select_edges( from = 2, to = 3) # Get the inital edge selection graph %>% get_selection() #> [1] 1 3 # Traverse to the reverse edges # (edges `2`: `4`->`1` and # `4`:`3`->`2`) graph <- graph %>% trav_reverse_edge() # Get the current selection of edges graph %>% get_selection() #> [1] 2 4"},{"path":"/reference/trigger_graph_actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Trigger the execution of a series of graph actions — trigger_graph_actions","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"Execute graph actions stored graph use add_graph_action() function. actions invoked order errors encountered trigger warning message result change input graph. Normally, graph actions automatically triggered every transformation step function allows manual triggering graph actions setting , example.","code":""},{"path":"/reference/trigger_graph_actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"","code":"trigger_graph_actions(graph)"},{"path":"/reference/trigger_graph_actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/trigger_graph_actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trigger_graph_actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) # Add a graph action that sets a node # attr column with a function; this # uses the `get_pagerank()` function # to provide PageRank values in the # `pagerank` column graph <- graph %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\", action_name = \"get_pagerank\") # Add a second graph action (to be # executed after the first one) that # rescales values in the `pagerank` # column between 0 and 1, and, puts # these values in the `width` column graph <- graph %>% add_graph_action( fcn = \"rescale_node_attrs\", node_attr_from = \"pagerank\", node_attr_to = \"width\", action_name = \"pgrnk_to_width\") # Add a third and final graph action # (to be executed last) that creates # color values in the `fillcolor` column, # based on the numeric values from the # `width` column graph <- graph %>% add_graph_action( fcn = \"colorize_node_attrs\", node_attr_from = \"width\", node_attr_to = \"fillcolor\", action_name = \"pgrnk_fillcolor\") # View the graph actions for the graph # object by using the `get_graph_actions()` # function graph %>% get_graph_actions() #> # A tibble: 3 × 3 #> action_index action_name expression #> #> 1 1 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_fcn… #> 2 2 pgrnk_to_width rescale_node_attrs(graph = graph, node_attr_from… #> 3 3 pgrnk_fillcolor colorize_node_attrs(graph = graph, node_attr_fro… # Manually trigger to invocation of # the graph actions using the # `trigger_graph_actions()` function graph <- graph %>% trigger_graph_actions() # Examine the graph's internal node # data frame (ndf) to verify that # the `pagerank`, `width`, and # `fillcolor` columns are present graph %>% get_node_df() #> id type label pagerank width fillcolor #> 1 1 1 0.2877 0.935 #ABDDA4 #> 2 2 2 0.0940 0.000 #D7191C #> 3 3 3 0.3012 1.000 #2B83BA #> 4 4 4 0.1965 0.495 #FFFFBF #> 5 5 5 0.1206 0.128 #FDAE61"},{"path":"/reference/usd_exchange_rates.html","id":null,"dir":"Reference","previous_headings":"","what":"US Dollar exchange rates. — usd_exchange_rates","title":"US Dollar exchange rates. — usd_exchange_rates","text":"dataset containing exchange rates USD currencies.","code":""},{"path":"/reference/usd_exchange_rates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"US Dollar exchange rates. — usd_exchange_rates","text":"","code":"usd_exchange_rates"},{"path":"/reference/usd_exchange_rates.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"US Dollar exchange rates. — usd_exchange_rates","text":"data frame 196 rows 3 variables: from_currency currency units used buy units alternate currency (always USD) to_currency currency bought cost_unit cost per unit currency bought","code":""},{"path":"/reference/visnetwork.html","id":null,"dir":"Reference","previous_headings":"","what":"Render graph with visNetwork — visnetwork","title":"Render graph with visNetwork — visnetwork","text":"Render graph object visNetwork R package.","code":""},{"path":"/reference/visnetwork.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render graph with visNetwork — visnetwork","text":"","code":"visnetwork(graph)"},{"path":"/reference/visnetwork.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render graph with visNetwork — visnetwork","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/visnetwork.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render graph with visNetwork — visnetwork","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 6, label = TRUE, fillcolor = c(\"lightgrey\", \"red\", \"orange\", \"pink\", \"aqua\", \"yellow\"), shape = \"dot\", size = c(20, 80, 40, 10, 30, 50), type = c(\"1\", \"1\", \"1\", \"2\", \"2\", \"2\") ) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3, 4, 6, 5), to = c(4, 3, 1, 3, 1, 4), color = c(\"green\", \"green\", \"grey\", \"grey\", \"blue\", \"blue\"), rel = \"leading_to\" ) # Create a graph object graph <- create_graph( nodes_df = ndf, edges_df = edf ) # visnetwork(graph)"},{"path":"/reference/x11_hex.html","id":null,"dir":"Reference","previous_headings":"","what":"X11 colors and hexadecimal color values — x11_hex","title":"X11 colors and hexadecimal color values — x11_hex","text":"Create data frame containing information X11 colors corresponding hexadecimal color values.","code":""},{"path":"/reference/x11_hex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"X11 colors and hexadecimal color values — x11_hex","text":"","code":"x11_hex()"},{"path":"/news/index.html","id":"diagrammer-development-version","dir":"Changelog","previous_headings":"","what":"DiagrammeR (development version)","title":"DiagrammeR (development version)","text":"DiagrammeR nows uses testthat 3rd edition (@olivroy, #498) longer use deprecated features igraph tidyselect (>= 1.2.0) (@olivroy, #497) Error messages reviewed now use cli (@olivroy, #499, #502) now easier install suggested packages fly. DiagrammeR now uses rlang::check_installed() internally. (@olivroy, #499)","code":""},{"path":"/news/index.html","id":"diagrammer-1010","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.10","title":"DiagrammeR 1.0.10","text":"CRAN release: 2023-05-18 Remove dependency influenceR package, also means removing get_constraint() get_bridging() graph inspection functions.","code":""},{"path":"/news/index.html","id":"diagrammer-109","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.9","title":"DiagrammeR 1.0.9","text":"CRAN release: 2022-03-05 safely check inputs grViz() mermaid()","code":""},{"path":"/news/index.html","id":"diagrammer-108","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.8","title":"DiagrammeR 1.0.8","text":"CRAN release: 2022-01-24 Reduce minimum R version requirement.","code":""},{"path":"/news/index.html","id":"diagrammer-107","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.7","title":"DiagrammeR 1.0.7","text":"CRAN release: 2022-01-15 Fix malformed CSS selector htmlwidgets/grViz.js call replace_na(replace = \"\") character columns Added envir argument grViz replace_in_spec functions.","code":""},{"path":"/news/index.html","id":"diagrammer-1061","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.6.1","title":"DiagrammeR 1.0.6.1","text":"CRAN release: 2020-05-08 Removed set_df_as_node_attr(), set_df_as_edge_attr(), get_attr_dfs() functions.","code":""},{"path":"/news/index.html","id":"diagrammer-105","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.5","title":"DiagrammeR 1.0.5","text":"CRAN release: 2020-01-16 Removes ability save DiagrammeR graph object Gephi file (.gexf) since rgexf package longer maintained","code":""},{"path":"/news/index.html","id":"diagrammer-100","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.0","title":"DiagrammeR 1.0.0","text":"CRAN release: 2018-03-01 Added helper functions node_aes(), node_data(), edge_aes(), edge_data() facilitate binding node edge aesthetic data attribute values; several functions now namesake arguments accept functions’ output. Information graph now displayed console graph object called Error messages now helpful try provide pointers common errors","code":""},{"path":"/news/index.html","id":"diagrammer-092","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.9.2","title":"DiagrammeR 0.9.2","text":"CRAN release: 2017-09-06 Added functions generate 2D 3D grid graphs (add_grid_2d() add_grid_3d()) Added _ws (selection) variants mutate_[node/edge]_attrs() functions mutating node edge attributes nodes/edges active selection Incorporated edges argument select_edges() function order filter selection edges set edge ID values Reduced dependency R version >= 3.2.0","code":""},{"path":"/news/index.html","id":"diagrammer-092-1","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.9.2","title":"DiagrammeR 0.9.2","text":"CRAN release: 2017-09-06 Added functions generate 2D 3D grid graphs (add_grid_2d() add_grid_3d()) Added _ws (selection) variants mutate_[node/edge]_attrs() functions mutating node edge attributes nodes/edges active selection Incorporated edges argument select_edges() function order filter selection edges set edge ID values Reduced dependency R version >= 3.2.0","code":""},{"path":"/news/index.html","id":"diagrammer-091","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.9.1","title":"DiagrammeR 0.9.1","text":"CRAN release: 2017-08-21 Simplified many functions internally Added default print method graph objects Allowed use bare node edge attribute names many functions Implemented graph actions means run one functions every graph transformation step; example, can used automatically update node attribute betweenness whenever modifications graph made (e.g., adding nodes, removing edges, etc.) Data frames can set node edge attributes set_df_as_node_attr() set_df_as_edge_attr() functions; get_attr_dfs() function allows retrieval stored data frame data Added two new graph-generating functions (add_gnp_graph(), add_pa_graph(), create_complement_graph()) Added functions clone existing nodes edges (add_n_node_clones() add_edge_clone()) Added several count_* functions (count_asymmetric_node_pairs(), count_automorphisms(), etc.) Added new functions obtain graph properties (get_adhesion(), get_girth(), get_reciprocity(), etc.) Added several is_* functions graph edge properties (e.g., is_edge_loop(), is_graph_dag(), etc.) mutate_node_attrs() mutate_edge_attrs() functions now simpler powerful interfaces mutating node edge attributes Graphs can easily saved disk (read disk) using save_graph() open_graph() functions","code":""},{"path":"/news/index.html","id":"diagrammer-090","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.9.0","title":"DiagrammeR 0.9.0","text":"CRAN release: 2017-01-03 Modified basic structure node edge data frames ID values automatically set integer values Just nodes , edges now edge ID values (can obtained using get_edge_ids() can used directly select_edges_by_edge_id() function) created, graph object automatically generates graph ID graph name (can modified using set_graph_name()) long node label values unique, may now used compose edges using add_edge() function use_labels = TRUE Quickly flexibly add color nodes edges using colorize_node_attrs() colorize_edge_attrs() functions Added functions selectively modify existing node edge attributes: copy_[node/edge]_attrs(), drop_[node/edge]_attrs(), mutate_[node/edge]_attrs(), recode_[node/edge]_attrs(), rename_[node/edge]_attrs(), rescale_[node/edge]_attrs(). New node edge attributes can now easily added graph via data frame using join_node_attrs() join_edge_attrs() functions Several graph generators available quickly adding graph primitives graph object (add_balanced_tree(), add_cycle(), add_full_graph(), add_path(), add_prism(), add_star()) traversal functions can now migrate numeric node edge attribute values traversed edges (e.g., trav_out_edge(), trav_in_node()) providing attribute name copy_attrs_from; traversal functions nodes edges may receive multiple values, one can specify aggregation type agg argument (e.g,. trav_in_node(), trav_both_edge()) Multiple conditions can specified traversal types select_nodes() select_edges() functions, plus, much easier write Added mk_cond() helper function creating conditions traversal functions (trav_...()), , select_nodes() select_edges() functions; helper allows easier composition selection/traversal conditions using variables /function calls selection edges one can now use select_rev_edges_ws() transform selection selected edges’ reverse edges (available); option add reverse edges edge selection simply replace current selection Caching attributes later use made simpler collection cache_...() functions (, set cache explicitly using set_cache()); get graph’s cache using get_cache() function Added functions allow layout control nodes (set_node_position(), layout_nodes_w_string(), nudge_node_positions()) Added functions convert DiagrammeR graphs igraph graphs vice versa (to_igraph(), from_igraph()) Now can create graph adjacency matrix (from_adj_matrix()) Added functions get community membership variety algorithms: get_cmty_edge_btwns(), get_cmty_fast_greedy(), get_cmty_l_eigenvec(), get_cmty_louvain(), get_cmty_walktrap(). Added functions determine similarity coefficient scores graph nodes: get_dice_similarity() get_dice_similarity(). Constraint scores nodes can now determined using get_constraint() function Functions getting information nodes neighbors added: get_nbrs(), get_non_nbrs(), get_similar_nbrs(). Groups nodes weakly strongly connected components can determined using get_w_connected_cmpts() get_s_connected_cmpts() functions Get articulation points (.e., nodes , removed, disconnect graph) get_articulation_points() function Obtain centrality measures graph nodes using get_closeness() get_betweenness() functions Get minimum-spanning tree subgraph graph weighted edges using get_min_spanning_tree() function edge direction may reversed entire graph (rev_edge_dir()) part graph using edge selection (rev_edge_dir_ws()) Depth-first search breadth-first search algorithms available do_dfs() do_bfs() functions Degree data plots can now easily obtained using get_degree_distribution() get_degree_histogram() functions Global graph attributes now easily modifiable using set functions purpose: add_global_graph_attrs(), delete_global_graph_attrs(), get_global_graph_attr_info(). Added option display different text labels nodes via display node attribute; easily set set_node_attr_to_display() function Rewrote many graph functions (e.g. traversals) faster large graphs log graph functions directly modify graph now part graph object (graph$graph_log) Added functionality automatically generate graph backups every graph modification; form RDS files deposited subdirectory (name based graph ID) working directory; option (write_backups, set FALSE default) available functions initialize graph object (create_graph(), create_random_graph(), from_igraph(), from_adj_matrix())","code":""},{"path":"/news/index.html","id":"diagrammer-08","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.8","title":"DiagrammeR 0.8","text":"CRAN release: 2015-10-08 Revised many graph functions work better together Added many testthat tests maintain quality graph functions Added functions create_random_graph(), import_graph(), combine_graphs(), country_graph() select_graph_from_series() Added support visNetwork graphs rendering option render_graph()","code":""},{"path":"/news/index.html","id":"diagrammer-07","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.7","title":"DiagrammeR 0.7","text":"CRAN release: 2015-06-11 Renamed functions graphviz_graph() graphviz_render() create_graph() render_graph(), respectively Removed function graphviz_export() (exporting now handled render_graph()) Added several new functions inspect, analyze, modify graphs: display_graph_object(), node_info(), edge_info(), node_present(), edge_present(), get_nodes(), get_edges(), get_predecessors(), get_successors(), node_count(), edge_count(), is_graph_empty(), is_graph_directed(), add_node(), add_edges(), delete_node(), delete_edge(), node_type(), edge_relationship(), create_series(), add_to_series(), remove_from_series(), graph_count(), subset_series(), trigger_script(), render_graph_from_series(), series_info()","code":""},{"path":"/news/index.html","id":"diagrammer-06","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.6","title":"DiagrammeR 0.6","text":"CRAN release: 2015-04-30 Added several functions work graphs: create_nodes(), create_edges(), combine_nodes(), combine_edges(), scale_nodes(), scale_edges(), get_nodes(), node_info(), graphviz_graph(), graphviz_render(), graphviz_export() Removed graphviz_nodes_edges_df() graphviz_single_df() functions","code":""},{"path":"/news/index.html","id":"diagrammer-05","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.5","title":"DiagrammeR 0.5","text":"CRAN release: 2015-03-19 Added support subgraphs Gantt charts mermaid diagrams Added function graphviz_nodes_edges_df() generating Graphviz DOT code defines nodes edges (attributes) data two data frames: one nodes, edge operations Added function graphviz_single_df() generating Graphviz DOT code single data frame Incorporated new substitution operators @_{...} @^{...} grViz statements subscripting superscripting, respectively","code":""},{"path":"/news/index.html","id":"diagrammer-04","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.4","title":"DiagrammeR 0.4","text":"CRAN release: 2015-01-30 Added support substitution Graphviz graph specifications Added support Graphviz diagrams Shiny app","code":""},{"path":"/news/index.html","id":"diagrammer-03","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.3","title":"DiagrammeR 0.3","text":"Added support Graphviz neato, twopi, circo engines","code":""},{"path":"/news/index.html","id":"diagrammer-02","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.2","title":"DiagrammeR 0.2","text":"Added viz.js library enable Graphviz support","code":""},{"path":"/news/index.html","id":"diagrammer-01","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.1","title":"DiagrammeR 0.1","text":"CRAN release: 2015-01-09 Initial release Incorporated htmlwidgets framework Added basic shiny app","code":""}] +[{"path":[]},{"path":"/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement riannone@.com. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2014-2023 DiagrammeR authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"graphviz","dir":"Articles","previous_headings":"","what":"Graphviz","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz support integral part DiagrammeR package. Graphviz consists graph description language called DOT language also comprises various tools can process DOT language. DOT highly customizable allows control line colors, arrow shapes, node shapes, many layout features.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"diagrammer-implementation","dir":"Articles","previous_headings":"","what":"DiagrammeR Implementation","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz graphs, DiagrammeR uses processing function called grViz(). pass grViz() valid graph specification DOT language. DOT graph description can either delivered grViz() form string, reference Graphviz file (.gv file extension), text connection. code examples provided later sections call grViz() function R script pass graph description string. important consider strings R contain unescaped double-quote characters. However, grViz() function allows single-quote characters place. convenience, DOT graph description supplied file (e.g., dot-graph.gv) text connection, either format quotes accepted. recent builds RStudio, use external text file .gv file extension can provide advantage syntax coloring previewing RStudio Viewer pane saving ('Preview Save' selected), , pressing 'Preview' button Source pane.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"defining-a-graphviz-graph","dir":"Articles","previous_headings":"","what":"Defining a Graphviz Graph","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz graph specification must begin directive stating whether directed graph (digraph) undirected graph (graph) desired. Semantically, indicates whether natural direction one edge’s nodes . optional graph ID follows paired curly braces denotes body statement list (stmt_list). Optionally, graph may also described strict. forbids creation multi-edges (.e., can one edge given tail node head node directed case). undirected graphs, can one edge connected two nodes. Subsequent edge statements using two nodes identify edge previously defined one apply attributes given edge statement. basic structure:","code":"[strict] (graph | digraph) [ID] '{' stmt_list '}'"},{"path":"/articles/graphviz-mermaid.html","id":"statements","dir":"Articles","previous_headings":"","what":"Statements","title":"Graphviz and mermaid in DiagrammeR","text":"graph statement (graph_stmt), node statement (node_stmt), edge statement (edge_stmt) three commonly used statements Graphviz DOT language. Graph statements allow attributes set components graph. Node statements define provide attributes graph nodes. Edge statements specify edge operations nodes supply attributes edges. edge operations, directed graph must specify edge using edge operator -> undirected graph must use -- operator. Within statements follow statement lists. Thus node statement, list nodes expected. edge statement, list edge operations. list items can optionally attribute list (attr_list) modify attributes either node edge. Comments may placed within statement list. can marked using // /* */ structure. Comment lines denoted # character. Multiple statements within statement list can separated linebreaks ; characters multiple statements example nodes (case styled boxes circles) can easily defined along connections:","code":"grViz(\" digraph boxes_and_circles { # a 'graph' statement graph [overlap = true, fontsize = 10] # several 'node' statements node [shape = box, fontname = Helvetica] A; B; C; D; E; F node [shape = circle, fixedsize = true, width = 0.9] // sets as circles 1; 2; 3; 4; 5; 6; 7; 8 # several 'edge' statements A->1 B->2 B->3 B->4 C->A 1->D E->A 2->4 1->5 1->F E->6 4->6 5->7 6->7 3->8 } \")"},{"path":"/articles/graphviz-mermaid.html","id":"subgraphs-and-clusters","dir":"Articles","previous_headings":"","what":"Subgraphs and Clusters","title":"Graphviz and mermaid in DiagrammeR","text":"Subgraphs play three roles Graphviz. First, subgraph can used represent graph structure, indicating certain nodes edges grouped together. usual role subgraphs typically specifies semantic information graph components. can also provide convenient shorthand edges. edge statement allows subgraph left right sides edge operator. occurs, edge created every node left every node right. example, specification equivalent second role, subgraph can provide context setting attributes. example, subgraph specify blue default color nodes defined . context graph drawing, interesting example anonymous subgraph specifies nodes , B, C placed rank. third role subgraphs directly involves graph laid certain layout types. name subgraph begins cluster, Graphviz notes subgraph special cluster subgraph. supported, layout make nodes belonging cluster drawn together, entire drawing cluster contained within bounding rectangle.","code":"A -> {B C} A -> B A -> C subgraph { rank = same; A; B; C; }"},{"path":"/articles/graphviz-mermaid.html","id":"graphviz-attributes","dir":"Articles","previous_headings":"","what":"Graphviz Attributes","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz attributes allow style Graphviz graph. Combinations attributes nodes, edges, clusters, entire graph provide highly-customized layouts.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"node-attributes","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Node Attributes","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz attributes specified name-value pairs. Thus, set fillcolor node abc, one use lots node attributes. following provides visual guide notable ones.","code":"abc [fillcolor = red]"},{"path":"/articles/graphviz-mermaid.html","id":"edge-attributes","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Edge Attributes","title":"Graphviz and mermaid in DiagrammeR","text":"Edge attributes set way node attributes. example, set arrowhead style edge abc -> def, one use Quotation marks important multiword attributes, might used label attribute. Refer following important edge attributes","code":"abc -> def [arrowhead = diamond]"},{"path":"/articles/graphviz-mermaid.html","id":"colors","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Colors","title":"Graphviz and mermaid in DiagrammeR","text":"default, Graphviz can use colors provided hexadecimal values, , X11 color names. following provides entire list X11 color names. colors additional 4-color palettes based named color. additional colors can used appending digits 1-4 color name. Gray (grey) variations 0-100. Please note , color names, gray interchangeable grey.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"node-shapes","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Node Shapes","title":"Graphviz and mermaid in DiagrammeR","text":"’s shortage shapes available nodes. Nodes can changed default ellipse shape using shape parameter. table provides listing possible node shapes.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"arrow-shapes","dir":"Articles","previous_headings":"Graphviz Attributes","what":"Arrow Shapes","title":"Graphviz and mermaid in DiagrammeR","text":"shapes arrows highly customizable. defining edge, arrowhead parameter allows change style arrowhead default normal arrow shape, one several others. arrowhead types used.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"graphviz-substitution","dir":"Articles","previous_headings":"","what":"Graphviz Substitution","title":"Graphviz and mermaid in DiagrammeR","text":"Graphviz substitution allows mixing R expressions Graphviz DOT graph specification without sacrificing readability.","code":""},{"path":"/articles/graphviz-mermaid.html","id":"how-it-works","dir":"Articles","previous_headings":"Graphviz Substitution","what":"How It Works","title":"Graphviz and mermaid in DiagrammeR","text":"take advantage substitution rendering graph, simply use grViz() function Graphviz DOT code: notation @@ within GraphViz DOT graph specification indicate substitution take place. Corresponding R expressions (formal graph specification, styled footnotes) provide values substituted. grViz() function autodetect whether working Graphviz DOT graph specification contains @@s curly braces [graph|digraph] {...} DOT construction. specify substitution @@, must ensure valid expression substitution. expressions placed footnotes evaluations must result R vector object (.e., data frame, list, matrix). possibility multiple substitutions, numbering required. Thus, @@ notation immediately followed number number correspond number footnoted R expression. substitution construction : Importantly, footnote expressions reside closing curly brace graph digraph expression. always take form : simple example specifying single node, following substitution syntax used: example, [1]: footnote expression evaluates '', , ’s substituted place @@1 (resultant , turn, taken node ID). Substitutions can also used insert values vector indices graph specification. Simply use format: ’s example specific values vectors can inserted graph: evaluation footnote expressions substitution, graph specification becomes :","code":"grViz(\" [...graph spec with substitutions using @@ notation and footnote R expressions...] \") \"@@\" + [footnote number] \"[\" + [footnote number] + \"]:\" digraph { @@1 } [1]: 'a' \"@@\" + [footnote number] + \"-\" + [index number] digraph alpha { @@1-1; @@1-2; @@1-3; @@1-4; @@1-5 @@1-6; @@1-7; @@1-8; @@1-9; @@1-10 } [1]: LETTERS digraph alpha { A; B; C; D; E F; G; H; I; J }"},{"path":"/articles/graphviz-mermaid.html","id":"examples","dir":"Articles","previous_headings":"Graphviz Substitution","what":"Examples","title":"Graphviz and mermaid in DiagrammeR","text":"best way demonstrate substitution works set examples. example substituting alphabet letters R’s LETTERS constant Graphviz graph specification. can mix substitutions single-values objects specifying indices R vector objects. example: can seen output: node ID given label “top” (substituting @@1 expression [1]: footnote R expression) nodes ID values b j respectively provided values indices 1 9 (using hyphenated form @@) evaluated expression 10:20 ([2]: footnote expression) Footnote expressions meant flexible. can span multiple lines, can also take objects available global workspace. , long vector object results evaluation, substitution can performed.","code":"grViz(\" digraph a_nice_graph { # node definitions with substituted label text node [fontname = Helvetica] a [label = '@@1'] b [label = '@@2-1'] c [label = '@@2-2'] d [label = '@@2-3'] e [label = '@@2-4'] f [label = '@@2-5'] g [label = '@@2-6'] h [label = '@@2-7'] i [label = '@@2-8'] j [label = '@@2-9'] # edge definitions with the node IDs a -> {b c d e f g h i j} } [1]: 'top' [2]: 10:20 \")"},{"path":"/articles/node-edge-data-frames.html","id":"node-and-edge-data-frames","dir":"Articles","previous_headings":"","what":"Node and Edge Data Frames","title":"Node and Edge Data Frames","text":"functions used create manipulate specialized data frames: node data frames (NDFs) edge data frames (EDFs). functions useful one can selectively add field data data frames combine necessary addition graph object.","code":""},{"path":"/articles/node-edge-data-frames.html","id":"creating-an-ndf","dir":"Articles","previous_headings":"","what":"Creating an NDF","title":"Node and Edge Data Frames","text":"create_node_df() function, one can create node data frame (NDF) nodes attributes. object really just R data.frame object. cases, ’s recommended use create_node_df() instead data.frame() (, .data.frame()) create NDF. Using create_node_df() allows validation input data (integrity graph compromised) function provides additional functionality base R functions data frame creation : single values repeated n number nodes supplied selective setting attributes (e.g., giving attr values 3 10 nodes, allowing non-set nodes use defaults globally set attr values) supplying overlong vectors attributes result trimming number nodes setting label = FALSE conveniently result non-labeled node function one argument requires values supplied: nodes argument. Just supplying set unique ID values nodes create NDF nodes additional attributes. incorporated graph, NDF parsed column names match keywords node attributes indicate DiagrammeR values columns provide attribute values per-node basis. Columns names don’t match reserved attribute names disregarded , , can include columns useful data analysis. creating node data frame, one column named nodes created (first column NDF). ’s unique values node ID reside. attribute columns, type label columns also created. However, necessarily need populated values thus can left blank, desired. attributes voluntarily added named vectors R triple-dot (...) argument. node attribute names types values supply: color — provide X11 hexadecimal color (append 2 digits hex alpha) distortion — node distortion shape = polygon fillcolor — provide X11 hexadecimal color (append 2 digits hex alpha) fixedsize — true false fontcolor — provide X11 hexadecimal color (append 2 digits hex alpha) fontname — name font fontsize — size font node label height — height node penwidth — thickness stroke shape peripheries — number peripheries (essentially, additional shape outlines) shape — node shape (e.g., ellipse, polygon, circle, etc.) sides — shape = polygon, number sides can provided style — usually given value filled ’d like fill node color tooltip — provide text unstyled browser tooltip width — width node x — x position node (requires graph attr layout = neato use) y — y position node (requires graph attr layout = neato use) following examples, node data frames created. worthwhile things notice . nodes can supplied character vector (c(\"\", \"b\", \"c\", \"d\")), , range integers (1:4). may matter preference, numbering system seems better choice (functions available package take advantage graph ID values available monotonically increasing integer values). Secondly, single logical value can supplied label argument, TRUE copies node ID label attribute, FALSE yields blank, unset value nodes NDF. Finally, provision single values call creates single node result nodes attribute (e.g., color = \"aqua\" sets nodes NDF ‘aqua’ color).","code":"# Create a node data frame nodes_1 <- create_node_df( n = 4, type = \"lower\", label = c(\"a\", \"b\", \"c\", \"d\"), style = \"filled\", color = \"aqua\", shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), data = c(3.5, 2.6, 9.4, 2.7)) # Inspect the `nodes_1` NDF nodes_1 #> id type label style color shape data #> 1 1 lower a filled aqua circle 3.5 #> 2 2 lower b filled aqua circle 2.6 #> 3 3 lower c filled aqua rectangle 9.4 #> 4 4 lower d filled aqua rectangle 2.7 # Create another node data frame nodes_2 <- create_node_df( n = 4, type = \"upper\", label = TRUE, style = \"filled\", color = \"red\", shape = \"triangle\", data = c(0.5, 3.9, 3.7, 8.2)) # Inspect the `nodes_2` NDF nodes_2 #> id type label style color shape data #> 1 1 upper 1 filled red triangle 0.5 #> 2 2 upper 2 filled red triangle 3.9 #> 3 3 upper 3 filled red triangle 3.7 #> 4 4 upper 4 filled red triangle 8.2"},{"path":"/articles/node-edge-data-frames.html","id":"creating-an-edf","dir":"Articles","previous_headings":"","what":"Creating an EDF","title":"Node and Edge Data Frames","text":"Using create_edge_df() function, edge data frame (EDF) (comprising edges attributes) created. create_node_df() function, resulting object R data.frame object. usual means creating data frames used create EDF, create_edge_df() function provides conveniences validation final object (e.g., checking uniqueness supplied node ID values). Also, special attribute edge called rel, short relationship. optional attribute, , can left blank. However, ’s advantageous types group labels set edges, especially resulting graph fashioned property graph. (node type values must also set node model graph property graph.) Edges define connections nodes graph. , sense, edge data frame complementary component node data frame within graph. Therefore, EDF contains node ID information two columns named . , making edge data frame, two equal-length vectors need supplied create_edge_df() function: one outgoing node edge (), , another incoming node edge (). two columns contain node ID values. node data frame, attributes can provided edges. following edge attributes can used: arrowhead — arrow style head end (e.g, normal, dot) arrowsize — scaling factor arrowhead arrowtail arrowtail — arrow style tail end (e.g, normal, dot) color — stroke color; X11 color hex code (add 2 digits alpha) dir — direction; either forward, back, , none fontcolor — choose X11 color provide hex code (append 2 digits alpha) fontname — name font fontsize — size font node label headport — cardinal direction arrowhead meets node label — label text line nodes minlen — minimum rank distance head tail penwidth — thickness stroke arrow tailport — cardinal direction tail emitted node tooltip — provide text edge tooltip examples edge data frames can created:","code":"# Create an edge data frame edges_1 <- create_edge_df( from = c(1, 1, 2, 3), to = c(2, 4, 4, 1), rel = \"requires\", color = \"green\", data = c(2.7, 8.9, 2.6, 0.6)) edges_1 #> id from to rel color data #> 1 1 1 2 requires green 2.7 #> 2 2 1 4 requires green 8.9 #> 3 3 2 4 requires green 2.6 #> 4 4 3 1 requires green 0.6 # Create another edge data frame edges_2 <- create_edge_df( from = c(5, 7, 8, 8), to = c(8, 8, 6, 5), rel = \"receives\", arrowhead = \"dot\", color = \"red\") edges_2 #> id from to rel arrowhead color #> 1 1 5 8 receives dot red #> 2 2 7 8 receives dot red #> 3 3 8 6 receives dot red #> 4 4 8 5 receives dot red"},{"path":"/articles/node-edge-data-frames.html","id":"combining-ndfs","dir":"Articles","previous_headings":"","what":"Combining NDFs","title":"Node and Edge Data Frames","text":"Several node data frames (NDFs) can combined one using combine_ndfs() function. can combine two NDFs single call combine_ndfs(), , combine even single pass. may occasion combine several NDFs single node data frame. combine_ndfs() function works much like base R rbind() function except accepts NDFs columns differing number, names, ordering. Obtaining several node data frames may result collecting data various sources, different times (collected data different), , simply multiple calls create_node_df() practical readability purposes, name examples. Speaking examples:","code":"# Create an NDF nodes_1 <- create_node_df( n = 4, label = 1:4, type = \"lower\", data = c(8.2, 5.2, 1.2, 14.9)) # Create another NDF nodes_2 <- create_node_df( n = 4, label = 5:8, type = \"upper\", data = c(0.3, 6.3, 10.7, 1.2)) # Combine the NDFs all_nodes <- combine_ndfs(nodes_1, nodes_2) all_nodes #> id type label data #> 1 1 lower 1 8.2 #> 2 2 lower 2 5.2 #> 3 3 lower 3 1.2 #> 4 4 lower 4 14.9 #> 5 5 upper 5 0.3 #> 6 6 upper 6 6.3 #> 7 7 upper 7 10.7 #> 8 8 upper 8 1.2"},{"path":"/articles/node-edge-data-frames.html","id":"combining-edfs","dir":"Articles","previous_headings":"","what":"Combining EDFs","title":"Node and Edge Data Frames","text":"may cases one might take data one data frames create multiple edge data frames. One can combine multiple edge data frames (EDFs) combine_edfs() function. number EDFs can safely combined one call function. , advantageous use combining function purpose coalescing EDFs. single, combined EDF generated, much easier incorporate data DiagrammeR graph object.","code":"# Create an edge data frame edges_1 <- create_edge_df( from = c(1, 1, 2, 3), to = c(2, 4, 4, 1), rel = \"requires\", color = \"green\", data = c(2.7, 8.9, 2.6, 0.6)) # Create another edge data frame edges_2 <- create_edge_df( from = c(5, 7, 8, 8), to = c(8, 8, 6, 5), rel = \"receives\", arrowhead = \"dot\", color = \"red\") # Combine edge data frames with 'combine_edfs' all_edges <- combine_edfs(edges_1, edges_2) all_edges #> id from to rel color data arrowhead #> 1 1 1 2 requires green 2.7 #> 2 2 1 4 requires green 8.9 #> 3 3 2 4 requires green 2.6 #> 4 4 3 1 requires green 0.6 #> 5 5 5 8 receives red NA dot #> 6 6 7 8 receives red NA dot #> 7 7 8 6 receives red NA dot #> 8 8 8 5 receives red NA dot"},{"path":"/articles/selections.html","id":"creating-a-node-selection","dir":"Articles","previous_headings":"","what":"Creating a Node Selection","title":"Selections","text":"Selecting nodes graph accomplished targeting specific node attribute (e.g., type, label, styling attributes width, available, arbitrary data values available nodes). select_*() functions, graph argument first function signature. beneficial forward-piping graph pipeline propagating series transformations graph. may situations several types selections applied graphs nodes edges (say, selecting nodes graph first step subtracting nodes specific type group) pipeline paradigm becomes incredibly useful, , added bonus, easy read reason . main handle selectivity select_nodes() function node attributes graph’s internal NDF, contains columns possible node attributes graph. providing expression conditions, nodes placed active selection TRUE. two common types expressions work well conditions argument: logical expression comparison operator (>, <, ==, !=) regular expression filtering via string matching Let’s create simple graph four nodes numeric data values. , ’ll inspect graph’s internal NDF see starting . first example, nodes selected based logical expression operating collection numeric values. examine result selection, get_node_df_ws() used. function display table active selection nodes graph (like get_node_df(), subset nodes). selection nodes can obtained match using regular expression operating collection character-based values (node attribute named fruits). uses grepl() function expression supplied conditions. regular expression use ^ap, ^ denotes beginning text parsed. situation may arise specialized match needs made (.e., matching , , matching two different types things). set_op argument can become useful. selection nodes obtained using select_nodes() (select_*() functions operate nodes), selection stored graph object. seen examples get_selection() used verify nodes selection. selection retained (least clear_selection() called, , selection edges made), multiple uses select_nodes() can modify set selected nodes depending option provided set_op argument. set operations : union: creates union selected nodes consecutive operations create selection nodes (default option) intersect: modifies list selected nodes nodes common consecutive node selection operations retained difference: modifies list selected nodes nodes retained different second node selection operation compared first set operations behave exactly base R functions: union(), intersect()/intersection(), setdiff() (actually used internally). Furthermore, select_*() functions contain set_op argument, , behave way regard modifying node edge selection pipeline selection operations. examples important fully understanding can work complex selections, quite provided . example graph now bit complex. contain 9 nodes, three different types (fruit, veg, nut). label node attribute name food, count attribute contains arbitrary numeric values. Let’s successively use two select_nodes() calls select foods either begin c end e. set, use union set operation second call select_nodes(). conditions don’t need related. first , ’s matching expression using grepl(). second filtering nodes count < 5. following example contains pair select_nodes() statements, first filters nodes fruit group (type == \"fruit\") excludes subset nodes (fruit containing “apple” name) using set_op = \"difference\". additional filtering option available nodes argument. , vector node ID values can supplied indicate function subset nodes considered select_nodes(). Note , nothing provided conditions nodes given vector node ID values, nodes make selection function call. convenient often good method selecting nodes (long one knows node IDs need selected), function select_nodes_by_id() handles use case directly (filters based nodes argument). Let’s now perform call select_nodes() contains expression conditions argument, , range node ID values nodes argument.","code":"# Create a node data frame ndf <- create_node_df( n = 4, data = c( 9.7, 8.5, 2.2, 6.0) ) # Create a new graph based on the ndf graph <- create_graph(nodes_df = ndf) # Inspect the graph's NDF graph %>% get_node_df() #> id type label data #> 1 1 9.7 #> 2 2 8.5 #> 3 3 2.2 #> 4 4 6.0 # Select nodes where the `data` attribute # has a value greater than 7.0 (it's the # first 2 nodes) graph <- graph %>% select_nodes( conditions = data > 7.0 ) # Get the graph's current selection # of nodes as a table graph %>% get_node_df_ws() #> id type label data #> 1 1 9.7 #> 2 2 8.5 # Create a node data frame ndf <- create_node_df( n = 4, fruits = c( \"apples\", \"apricots\", \"bananas\", \"plums\") ) # Create a new graph based on the ndf graph <- create_graph(nodes_df = ndf) # Select nodes where the `fruits` # attribute has a match on the first # letters being `ap` (the first 2 nodes) graph <- graph %>% select_nodes( conditions = grepl(\"^ap\", fruits) ) # Get the graph's current selection # of nodes as a table graph %>% get_node_df_ws() #> id type label fruits #> 1 1 apples #> 2 2 apricots # Create a node data frame ndf <- create_node_df( n = 9, type = c( \"fruit\", \"fruit\", \"fruit\", \"veg\", \"veg\", \"veg\", \"nut\", \"nut\", \"nut\"), label = c( \"pineapple\", \"apple\", \"apricot\", \"cucumber\", \"celery\", \"endive\", \"hazelnut\", \"almond\", \"chestnut\"), count = c( 6, 3, 8, 7, 2, 6, 9, 9, 7) ) # Create a new graph based on the ndf graph <- create_graph(nodes_df = ndf) # Inspect the graph's NDF graph %>% get_node_df() #> id type label count #> 1 1 fruit pineapple 6 #> 2 2 fruit apple 3 #> 3 3 fruit apricot 8 #> 4 4 veg cucumber 7 #> 5 5 veg celery 2 #> 6 6 veg endive 6 #> 7 7 nut hazelnut 9 #> 8 8 nut almond 9 #> 9 9 nut chestnut 7 # Select all foods that either begin # with `c` or ending with `e` graph_1 <- graph %>% select_nodes( conditions = grepl(\"^c\", label) ) %>% select_nodes( conditions = grepl(\"e$\", label), set_op = \"union\" ) # Get the graph's current selection # of nodes as a table graph_1 %>% get_node_df_ws() #> id type label count #> 1 1 fruit pineapple 6 #> 2 2 fruit apple 3 #> 3 4 veg cucumber 7 #> 4 5 veg celery 2 #> 5 6 veg endive 6 #> 6 9 nut chestnut 7 # Select any food beginning with `a` and # having a count less than 5 graph_2 <- graph %>% select_nodes( conditions = grepl(\"^a\", label) ) %>% select_nodes( conditions = count < 5, set_op = \"intersect\" ) # Get the graph's current selection # of nodes as a table graph_2 %>% get_node_df_ws() #> id type label count #> 1 2 fruit apple 3 # Select any fruit not containing # `apple` in its name graph_3 <- graph %>% select_nodes( conditions = type == \"fruit\" ) %>% select_nodes( conditions = grepl(\"apple\", label), set_op = \"difference\" ) # Get the graph's current selection # of nodes as a table graph_3 %>% get_node_df_ws() #> id type label count #> 1 3 fruit apricot 8 # Create a node data frame ndf <- create_node_df( n = 10, data = seq(0.5, 5, 0.5) ) # Create a new graph based on the ndf graph <- create_graph(nodes_df = ndf) # Inspect the graph's NDF graph %>% get_node_df() #> id type label data #> 1 1 0.5 #> 2 2 1.0 #> 3 3 1.5 #> 4 4 2.0 #> 5 5 2.5 #> 6 6 3.0 #> 7 7 3.5 #> 8 8 4.0 #> 9 9 4.5 #> 10 10 5.0 # Select from a subset of nodes # (given as `nodes = 1:6`) where # the `data` value is greater than `1.5` graph <- graph %>% select_nodes( conditions = data > 1.5, nodes = 1:6 ) # Get the graph's current selection # of nodes as a table graph %>% get_node_df_ws() #> id type label data #> 1 4 2.0 #> 2 5 2.5 #> 3 6 3.0"},{"path":"/articles/selections.html","id":"creating-an-edge-selection","dir":"Articles","previous_headings":"","what":"Creating an Edge Selection","title":"Selections","text":"Selecting edges graph done manner quite similar selecting nodes. primary means targeting specific edges available edge attributes (e.g., rel, styling attributes color, arbitrary data values available edges). start creating graph four nodes four edges. edges edge attribute called data contains numeric values. following example shows create selections edges based logical expression operating collection numeric values data attribute.","code":"# Create a node data frame ndf <- create_node_df(n = 4) # Create an edge data frame edf <- create_edge_df( from = c(1, 2, 3, 4), to = c(2, 3, 4, 1), data = c( 8.6, 2.8, 6.3, 4.5) ) # Create a new graph from # the NDF and EDF graph <- create_graph( nodes_df = ndf, edges_df = edf ) # Inspect the graph's EDF graph %>% get_edge_df() #> id from to rel data #> 1 1 1 2 8.6 #> 2 2 2 3 2.8 #> 3 3 3 4 6.3 #> 4 4 4 1 4.5 # Select edges where the `data` # attribute has a value # greater than 5.0 graph <- graph %>% select_edges( conditions = data > 5.0 ) # Get the graph's current selection # of edges as a table graph %>% get_edge_df_ws() #> id from to rel data #> 1 1 1 2 8.6 #> 2 3 3 4 6.3"},{"path":"/articles/selections.html","id":"selecting-the-last-node-or-edge-in-an-ndf-or-edf","dir":"Articles","previous_headings":"","what":"Selecting the Last Node or Edge in an NDF or EDF","title":"Selections","text":"can select last node edge graph’s internal node data frame (NDF) internal edge data frame (EDF), respectively. Usually, last node edge created since new nodes edges added bottom data frame shuffling positions. Immediately creating single node edge, calling either select_last_node() select_last_edge() functions result selection last node edge created. functions, graph argument. provide graph object select_last_nodes_created() get active selection nodes (last nodes added graph object). Likewise, select_last_edges_created() create active selection edges, whichever edges last defined function call. begin, ’ll use graph ’ll clear active selection using clear_selection() function. ensure active selection nodes edges, can use get_selection() function. value NA means neither selection nodes edges. use select_last_nodes_created graph, find active selection nodes contains nodes graph, produced create_graph() function (nodes added subsequent operations). goes edges. Using select_last_edges_created() make selection edges includes edges graph. functions become useful building graph multiple steps. next example, start empty graph (using create_graph() ) add single node add_node(), select node select_last_nodes_created(). selection---pipeline approach makes easy set node attributes can use set_node_attrs_ws() function. example, ’re adding new timestamp attribute assigning value (system time). selection persistent, can set attributes calls set_node_attrs_ws(). done node selection, call clear_selection() function return clean slate active selection present (removes node edge selection graph object). example proceeds create another new node adding attributes, new edge edge attributes (set_edge_attrs_ws()). facilitated select_last_nodes_created() select_last_edges_created() functions. graph shows two nodes connected together. Nothing , nothing less. interesting views data node edge data frames, now several attributes set. Let’s look graph’s internal node data frame… …let’s inspect graph’s internal edge data frame. can seen, immediately invoking select_last_nodes_created() select_last_edges_created() addition new nodes edges can useful working newly made nodes/edges. Many functions ending _ws() operate specifically selections nodes edges.","code":"# Clear the graph's selection graph <- graph %>% clear_selection() # Check whether there is still # a selection present graph %>% get_selection() #> [1] NA # Select the last node in the graph's NDF and confirm # that the selection was made graph %>% select_last_nodes_created() %>% get_node_df_ws() #> id type label #> 1 1 #> 2 2 #> 3 3 #> 4 4 # Select the last edge in the graph's EDF and confirm # that the selection was made graph %>% select_last_edges_created() %>% get_edge_df_ws() #> id from to rel data #> 1 1 1 2 8.6 #> 2 2 2 3 2.8 #> 3 3 3 4 6.3 #> 4 4 4 1 4.5 # Create a graph, node-by-node and # edge-by-edge and add attributes graph_2 <- create_graph() %>% add_node() %>% select_last_nodes_created() %>% set_node_attrs_ws( node_attr = \"timestamp\", value = as.character(Sys.time()) ) %>% set_node_attrs_ws( node_attr = \"type\", value = \"A\" ) %>% clear_selection() %>% add_node() %>% select_last_nodes_created() %>% set_node_attrs_ws( node_attr = \"timestamp\", value = as.character(Sys.time()) ) %>% set_node_attrs_ws( node_attr = \"type\", value = \"B\" ) %>% add_edge( from = 1, to = 2, rel = \"AB\" ) %>% select_last_edges_created() %>% set_edge_attrs_ws( edge_attr = \"timestamp\", value = as.character(Sys.time()) ) %>% clear_selection() # View the new graph graph_2 %>% render_graph() # Inspect the new graph's NDF graph_2 %>% get_node_df() #> id type label timestamp #> 1 1 A 2023-11-09 02:21:19.164171 #> 2 2 B 2023-11-09 02:21:19.19189 # Inspect the new graph's EDF graph_2 %>% get_edge_df() #> id from to rel timestamp #> 1 1 1 2 AB 2023-11-09 02:21:19.21292"},{"path":"/articles/simple-graphs-ndfs-edfs.html","id":"creating-a-graph-object","dir":"Articles","previous_headings":"","what":"Creating a Graph Object","title":"Creating Simple Graphs from NDFs/EDFs","text":"create_graph() function creates graph object. function also allows initialization graph name, setting node_df edge_df, graph theme. key options create_graph() function : nodes_df — optional data frame graph’s nodes (vertices) attributes edges_df — optional data frame edges nodes/vertices attributes directed — required logical value stating whether graph considered directed graph (TRUE, default) undirected graph (FALSE) graph_name — optional character vector name graph nodes_df edges_df arguments, one can supply node data frame edge data frame, respectively. dgr_graph object can initialized without nodes edges (supplying NDF EDF function call), favorable option supplying nodes edges using functions modify existing graph. example whereby empty graph (initialized directed graph) created. Note graph’s internal nodes_df edges_df data frames empty , signifying empty graph. ’s possible include NDF EDF calling create_graph(). get edgeless graph (graph nodes edges nodes. edges can always defined later (functions add_edge(), add_edge_df(), add_edges_from_table(), etc., functions covered subsequent section). Quite often, cases node edge attributes applied nodes edges graph. achieve , ’s need create columns NDFs EDFs attributes (repeat attribute values rows columns). Default graph attributes can provided graph graph_attrs, node_attrs, edge_attrs arguments. supply attributes, use vectors graph, node, edge attributes. want graph directed graph, value directed argument set TRUE (default value). Choose FALSE undirected graph. next example include nodes edges contained within graph object. case, values type rel attributes nodes edges, respectively, provided. Adding values attributes optional important data modeling work.","code":"# Create the graph object graph <- create_graph() # Get the class of the object class(graph) #> [1] \"dgr_graph\" # It's an empty graph, so the NDF has no rows get_node_df(graph) #> [1] id type label #> <0 rows> (or 0-length row.names) # The EDF doesn't have any rows either get_edge_df(graph) #> [1] id from to rel #> <0 rows> (or 0-length row.names) # By default, the graph is considered directed is_graph_directed(graph) #> [1] TRUE # Create a node data frame ndf <- create_node_df( n = 4, label = 1:4, type = \"lower\", style = \"filled\", color = \"aqua\", shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), data = c(3.5, 2.6, 9.4, 2.7) ) # Inspect the NDF ndf #> id type label style color shape data #> 1 1 lower 1 filled aqua circle 3.5 #> 2 2 lower 2 filled aqua circle 2.6 #> 3 3 lower 3 filled aqua rectangle 9.4 #> 4 4 lower 4 filled aqua rectangle 2.7 # Create the graph and include the # `nodes` NDF graph <- create_graph(nodes_df = ndf) # Examine the NDF within the graph object get_node_df(graph) #> id type label style color shape data #> 1 1 lower 1 filled aqua circle 3.5 #> 2 2 lower 2 filled aqua circle 2.6 #> 3 3 lower 3 filled aqua rectangle 9.4 #> 4 4 lower 4 filled aqua rectangle 2.7 # Check if it's the same NDF (both externally # and internally) all(ndf == graph %>% get_node_df()) #> [1] TRUE ### # Create a graph with both nodes and edges # defined, and, add some default attributes # for nodes and edges ### # Create a node data frame ndf <- create_node_df( n = 4, label = c(\"a\", \"b\", \"c\", \"d\"), type = \"lower\", style = \"filled\", color = \"aqua\", shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), data = c(3.5, 2.6, 9.4, 2.7) ) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\" ) graph <- create_graph( nodes_df = ndf, edges_df = edf ) %>% set_node_attrs( node_attr = \"fontname\", values = \"Helvetica\" ) %>% set_edge_attrs( edge_attr = \"color\", values = \"blue\" ) %>% set_edge_attrs( edge_attr = \"arrowsize\", values = 2 ) # Examine the NDF within the graph object get_node_df(graph) #> id type label style color shape data fontname #> 1 1 lower a filled aqua circle 3.5 Helvetica #> 2 2 lower b filled aqua circle 2.6 Helvetica #> 3 3 lower c filled aqua rectangle 9.4 Helvetica #> 4 4 lower d filled aqua rectangle 2.7 Helvetica # Have a look at the graph's EDF get_edge_df(graph) #> id from to rel color arrowsize #> 1 1 1 4 leading_to blue 2 #> 2 2 2 3 leading_to blue 2 #> 3 3 3 1 leading_to blue 2"},{"path":"/articles/simple-graphs-ndfs-edfs.html","id":"viewing-a-graph-object","dir":"Articles","previous_headings":"","what":"Viewing a Graph Object","title":"Creating Simple Graphs from NDFs/EDFs","text":"render_graph() function, ’s possible view graph object, , output DOT code current state graph. Let’s look graph created last example: ’d like return Graphviz DOT code (, perhaps, share use directly Graphviz command-line utility), can use generate_dot() function. ’s simple example:","code":"graph %>% render_graph() # Take the graph object and generate a character # vector with Graphviz DOT code (using cat() for # a better appearance) graph %>% generate_dot() %>% cat() #> digraph { #> #> graph [layout = 'neato', #> outputorder = 'edgesfirst', #> bgcolor = 'white'] #> #> node [fontname = 'Helvetica', #> fontsize = '10', #> shape = 'circle', #> fixedsize = 'true', #> width = '0.5', #> style = 'filled', #> fillcolor = 'aliceblue', #> color = 'gray70', #> fontcolor = 'gray50'] #> #> edge [fontname = 'Helvetica', #> fontsize = '8', #> len = '1.5', #> color = 'gray80', #> arrowsize = '0.5'] #> #> '1' [label = 'a', style = 'filled', color = 'aqua', shape = 'circle', fontname = 'Helvetica'] #> '2' [label = 'b', style = 'filled', color = 'aqua', shape = 'circle', fontname = 'Helvetica'] #> '3' [label = 'c', style = 'filled', color = 'aqua', shape = 'rectangle', fontname = 'Helvetica'] #> '4' [label = 'd', style = 'filled', color = 'aqua', shape = 'rectangle', fontname = 'Helvetica'] #> '1'->'4' [color = 'blue', arrowsize = '2'] #> '2'->'3' [color = 'blue', arrowsize = '2'] #> '3'->'1' [color = 'blue', arrowsize = '2'] #> }"},{"path":"/articles/traversals.html","id":"traversals-across-nodes","dir":"Articles","previous_headings":"","what":"Traversals Across Nodes","title":"Traversals","text":"traverse across connected nodes without regard properties edges nodes, three functions available: trav_out(), trav_in(), trav_both(). types traversals always require initial selection one nodes, , traversing, selection one nodes returned. Directionality traversal key differentiator three functions. trav_out() function allows traversals connected nodes outbound nodes relation origin nodes (directed graph). trav_in() function, movement reversed: traversals towards connected nodes inbound nodes. example, take edge described 1->2 origin node node ID 1; trav_out() function change node selection node 1 node 2 nodes adjacent edge leads origin node outbound node. node 1 outbound edges nodes (e.g., 1->{2,3,4}) nodes connected outbound edges origin node part new selection. Take another example central node selected node, node outbound inbound edges adjacent nodes: {2,3,4}->1->{5,6,7}. function trav_in() used, nodes 2, 3, 4 become selected nodes; using trav_out() result nodes 5, 6, 7 becoming selected nodes. several examples traversals across nodes. Let’s perform two types traversals single node using trav_out() trav_in(). First, ’ll create simple graph two nodes edge (1 -> 2). Starting node 1 (initial selection), traverse node 2. traversal can occur, selection altered. demonstrate, let’s use similar set steps graph opposite edge direction. type traversal can’t alter selection outbound edges node 1, just inbound edge (2 -> 1). make traversal possible, need use trav_in() function instead. Multiple traversals can made single set statements. Let’s create path graph containing five nodes add_path() function. obtain graph form: 1->2->3->4->5 can easily create initial selection node 1 select_nodes_by_id() function. several calls trav_out() succession, can move selection node 1 node 5. Traversals commonly performed initial selection contains multiple nodes (usually, nodes something common ). Let’s look slightly complex graph multiple nodes initial selection can migrated final selection traversal. can now take selection (still central node 1) traverse via outbound edges adjacent nodes: 2, 3, 4, 5, 6. Alternatively, initial selection 1 can traverse via inbound edges adjacent nodes (trav_in()) expect different final selection nodes (7, 8, 9, 10, 11). trav_both() function results traversals adjacent nodes regardless edge directions nodes. , sense, direction movement adjacent nodes , , . example {2,3,4}->1->{5,6,7}, node 1 node selection, nodes 2 node 6 part new selection calling trav_both(). far, functions described modifying selections nodes based solely node adjacency direction edges adjacent nodes. Indeed without supplying values function, traversals occur without regard attributes nodes traversed . However, arguments node_attr match available filtering traversals satisfy logical statements numeric attributes matches character attributes. property graph, values available nodes’ type attribute edges’ rel attribute, traversal trav_out() , example, performed outbound, adjacent nodes specific type label. done setting node_attr = type providing value type match argument. limited starting traversal single node ID value. can, example, begin selection nodes based regular expression traverse matching type string value (node attributes character values). following example uses random graph food entities arbitrary edges . Traversing node node trav_out(), trav_in(), trav_both() can result specific targeting nodes. seen, traversal occurred, new selection can used obtain data nodes, , modify graph (adding new nodes selection). Especially used within pipeline, selection nodes, traversals, resulting actions quite readable.","code":"pre <- create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 1, to = 2) %>% select_nodes_by_id(nodes = 1) # Create a simple graph, create a single- # node selection and traverse to the other # node; obtain the final selection create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 1, to = 2) %>% select_nodes_by_id(nodes = 1) %>% trav_out() %>% get_selection() #> [1] 2 # Create a simple graph, create a single- # node selection and then attempt to traverse # to the other node; obtain the final selection create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 2, to = 1) %>% select_nodes_by_id(nodes = 1) %>% trav_out() %>% get_selection() #> [1] 1 # A traversal can occur if `trav_in()` is used # instead of `trav_out()` create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 2, to = 1) %>% select_nodes_by_id(nodes = 1) %>% trav_in() %>% get_selection() #> [1] 2 # Traverse across a path graph one # step at a time with `trav_out()` create_graph() %>% add_path(n = 5) %>% select_nodes_by_id(nodes = 1) %>% trav_out() %>% trav_out() %>% trav_out() %>% trav_out() %>% get_selection() #> [1] 5 graph_1 <- create_graph() %>% add_node() %>% select_nodes_by_id(nodes = 1) %>% add_n_nodes_ws( n = 5, direction = \"from\" ) %>% add_n_nodes_ws( n = 5, direction = \"to\" ) graph_1 %>% render_graph() graph_1 %>% trav_out() %>% get_selection() #> [1] 2 3 4 5 6 graph_1 %>% trav_in() %>% get_selection() #> [1] 7 8 9 10 11 # Create the graph described in the paragraph # above ({`2...4`} -> `1` -> {`5...7`}), # start from node `1` (as a selection), # traverse to all other adjacent nodes and # then obtain the current selection create_graph() %>% add_node() %>% select_nodes_by_id(nodes = 1) %>% add_n_nodes_ws( n = 3, direction = \"to\" ) %>% add_n_nodes_ws( n = 3, direction = \"from\" ) %>% trav_both() %>% get_selection() #> [1] 2 3 4 5 6 7 # Create a common graph with nodes having # various `type` values; set to render # always using `visNetwork` when calling # `render_graph()` graph <- create_graph() %>% add_node(type = \"type_a\") %>% add_n_nodes( n = 4, type = \"type_b\" ) %>% add_edge(from = 1, to = 2) %>% add_edge(from = 1, to = 3) %>% add_edge(from = 4, to = 1) %>% add_edge(from = 5, to = 1) %>% add_n_nodes( n = 4, type = \"type_c\" ) %>% add_edge(from = 1, to = 6) %>% add_edge(from = 1, to = 7) %>% add_edge(from = 8, to = 1) %>% add_edge(from = 9, to = 1) # View the created graph graph %>% render_graph() graph %>% select_nodes_by_id(nodes = 1) %>% trav_out() %>% get_selection() #> [1] 2 3 6 7 graph %>% select_nodes_by_id(nodes = 1) %>% trav_out(conditions = type == \"type_b\") %>% get_selection() #> [1] 2 3 graph %>% select_nodes_by_id(nodes = 1) %>% trav_out(conditions = type == \"type_c\") %>% get_selection() #> [1] 6 7 # Once the nodes have been selected via # a traversal, a useful thing to do would # be to attach new nodes to that selection updated_graph <- graph %>% select_nodes_by_id(nodes = 1) %>% trav_out(conditions = type == \"type_c\") %>% add_n_nodes_ws( n = 1, direction = \"from\", type = \"type_d\" ) # View the updated graph updated_graph %>% render_graph() # Create a graph with fruit, vegetables, # and nuts ndf <- create_node_df( n = 9, type = c( \"fruit\", \"fruit\", \"fruit\", \"veg\", \"veg\", \"veg\", \"nut\", \"nut\", \"nut\" ), label = c( \"pineapple\", \"apple\", \"apricot\", \"cucumber\", \"celery\", \"endive\", \"hazelnut\", \"almond\", \"chestnut\" ) ) edf <- create_edge_df( from = c( 9, 3, 6, 2, 6, 2, 8, 2, 5, 5 ), to = c( 1, 1, 4, 3, 7, 8, 1, 5, 3, 6 ) ) graph <- create_graph( nodes_df = ndf, edges_df = edf ) # View the graph graph %>% render_graph() # View the internal NDF for sake of # reference graph %>% get_node_df() #> id type label #> 1 1 fruit pineapple #> 2 2 fruit apple #> 3 3 fruit apricot #> 4 4 veg cucumber #> 5 5 veg celery #> 6 6 veg endive #> 7 7 nut hazelnut #> 8 8 nut almond #> 9 9 nut chestnut # Select all nodes with a label beginning # with `a` and traverse outward to all nodes graph %>% select_nodes( conditions = grepl(\"^a\", label) ) %>% trav_out() %>% get_selection() #> [1] 1 3 5 8 # This traversal results in a rather large # selection of nodes: `3` (`apricot`), `8` # (`almond`), `5` (`celery`), and `1` # (`pineapple`) # Now, select all nodes with a label beginning # with `c` (in this case, the `cucumber` and # `chestnut` and then traverse outward to any # node of the `fruit` type graph %>% select_nodes( conditions = grepl(\"^c\", label) ) %>% trav_out( conditions = type == \"fruit\" ) %>% get_selection() #> [1] 1 3 # The traversal has resulted in a selection of # nodes `3` (`apricot`) and `1` (`pineapple`)"},{"path":"/articles/traversals.html","id":"traversals-from-nodes-to-edges","dir":"Articles","previous_headings":"","what":"Traversals from Nodes to Edges","title":"Traversals","text":"Moving across nodes using traversal functions quite powerful thing . However, especially information-rich graphs, useful data can exist graph’s edges. reason, can traverse nodes onto adjacent edges. node--node traversal functions, direction edge important key distinction functions trav_out_edge() trav_in_edge(). types traversals always begin nodes (thus require initial selection one nodes) typically end selection one edges. traversal can made, initial selection nodes retained. Starting trav_out_edge() function, suppose selection single node 1 simple graph 1->2. Calling trav_out_edge() function simplest form (without values supplied except graph ) result edge selection edge 1->2 edge. Thus, traversal one nodes onto adjacent, outward edges. graph, selection, calling trav_in_edge() function result traversal (initial node selection node 1 retained, though nothing happened). trav_in_edge() function performs converse traversal, traversal one nodes onto adjacent, inward edges. Put another way, trav_in_edge() change selection edges point toward initially-selected node(s), . node--node traversal functions, traversals much powerful used matching conditions increase selectivity. certain edges may traversed (selected) important, especially cases traversal continues onto nodes (next section). Examples aid understanding functions. introduce conditions traversal, can use conditions argument. node--node traversal functions, optional values induce filtering node--edge traversals. graph fashioned property graph values set node type edge rel attributes, traversals trav_out_edge() trav_in_edge() restricted selection edges specific rel label.","code":"# Create a simple graph with two nodes, an # edge between them (`1` -> `2`); starting # from node `1` (as a selection), traverse # to the edge and then obtain the current # selection create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 1, to = 2) %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge() %>% get_selection() #> [1] 1 # If no traversal can occur the selection is # not altered. To demonstrate, use a similar # pipeline but reverse the edge direction create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 2, to = 1) %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge() %>% get_selection() #> [1] 1 # A traversal can occur if `trav_in_edge()` # is used instead of `trav_out_edge()` create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 2, to = 1) %>% select_nodes_by_id(nodes = 1) %>% trav_in_edge() %>% get_selection() #> [1] 1 # A selection of multiple edges can occur # as a result of a traversal create_graph() %>% add_node() %>% select_nodes_by_id(nodes = 1) %>% add_n_nodes_ws( n = 10, direction = \"from\" ) %>% add_n_nodes_ws( n = 10, direction = \"to\" ) %>% trav_out_edge() %>% get_selection() #> [1] 1 2 3 4 5 6 7 8 9 10 create_graph() %>% add_node() %>% select_nodes_by_id(nodes = 1) %>% add_n_nodes_ws( n = 10, direction = \"from\" ) %>% add_n_nodes_ws( n = 10, direction = \"to\" ) %>% trav_in_edge() %>% get_selection() #> [1] 11 12 13 14 15 16 17 18 19 20 # First, set a seed so the example # is reproducible suppressWarnings(RNGversion(\"3.5.0\")) set.seed(20) # Create a graph with fruit, # vegetables, nuts, and... people! ndf <- create_node_df( n = 14, type = c( \"person\", \"person\", \"person\", \"person\", \"person\", \"fruit\", \"fruit\", \"fruit\", \"veg\", \"veg\", \"veg\", \"nut\", \"nut\", \"nut\" ), label = c( \"Annie\", \"Donna\", \"Justine\", \"Ed\", \"Graham\", \"pineapple\", \"apple\", \"apricot\", \"cucumber\", \"celery\", \"endive\", \"hazelnut\", \"almond\", \"chestnut\" ) ) edf <- create_edge_df( from = sort( as.vector(replicate(5, 1:5)) ), to = as.vector( replicate(5, sample(6:14, 5)) ), rel = as.vector( replicate( 5, sample( c( \"likes\", \"dislikes\", \"allergic_to\" ), 5, TRUE, c(0.5, 0.25, 0.25) ) ) ) ) graph <- create_graph( nodes_df = ndf, edges_df = edf ) graph %>% render_graph()"},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Richard Iannone. Author, maintainer. Olivier Roy. Author.","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Iannone R, Roy O (2023). DiagrammeR: Graph/Network Visualization. R package version 1.0.10.9000, https://github.com/rich-iannone/DiagrammeR, https://rich-iannone.github.io/DiagrammeR/.","code":"@Manual{, title = {DiagrammeR: Graph/Network Visualization}, author = {Richard Iannone and Olivier Roy}, year = {2023}, note = {R package version 1.0.10.9000, https://github.com/rich-iannone/DiagrammeR}, url = {https://rich-iannone.github.io/DiagrammeR/}, }"},{"path":"/index.html","id":"graph-basics","dir":"","previous_headings":"","what":"Graph Basics","title":"Graph/Network Visualization","text":"Let’s create graph object create_graph() add nodes edges . node gets new integer ID upon creation. edge also gets ID starting 1. pipes functions make whole process readable understandable. can take away edge using delete_edge(). can add node graph , time, defining edges existing nodes graph. Viewing graph object console provide basic information graph pointers get additional information. time add node edge graph, can add node edge aesthetic data attributes. can styling properties (e.g., color, shape), grouping labels (e.g., type rel), data values useful calculations display purposes. node edge creation functions (depending whether create either edges, nodes, ) arguments node_aes, edge_aes, node_data, edge_data. Using , can call namesake helper functions (node_aes(), edge_aes(), node_data(), edge_data()) specifically target created nodes edges bind attribute data. additional benefit using helper functions (node/edge aesthetic attributes especially) RStudio can provide inline help attribute names definitions typing node_aes( edge_aes( pressing TAB key. example adding node setting color, fillcolor, fontcolor node aesthetic attributes, , adding edge color, arrowhead, tooltip edge aesthetic attributes. add_node() add_edge() calls, new node edge set value node/edge data attribute. Creating attributes setting values often useful can work attributes (e.g., mutate values even use traversals). Furthermore, can create aesthetic properties based numerical categorical data. important want display graph diagram using render_graph() function. Don’t worry attribute values weren’t set right creation associated nodes edges. ways set attribute values existing nodes edges. Functions available targeting specific nodes/edges (.e., making selection) functions used set attribute values selected nodes edges. Often, can efficient strategy can target nodes/edges based properties (e.g., degree, relationships neighbors, etc.). example select node based value attribute modify color node aesthetic attribute: explain bit, take graph object d_graph, select nodes node value attribute exactly 2.5. (now active node selection.) selected nodes, set node attribute fillcolor value orange. deactivate selection clear_selection(). Now, view graph render_graph() get : quite functions allow select nodes (e.g., select_nodes(), select_nodes_by_id(), select_last_nodes_created()) edges (e.g., select_edges(), select_edges_by_edge_id(), select_last_edges_created()). selections, can apply changes using functions end ..._ws() (selection). seen, node attributes set/replaced set_node_attrs_ws() can also mutate attributes selected nodes (mutate_node_attrs_ws()), delete selected nodes (delete_nodes_ws()), even create subgraph selection (create_subgraph_ws()). Selections nodes edges can inverted (non-selected nodes edges become active selection) invert_selection(), certain nodes/edges can removed active selection deselect_nodes()/deselect_edges(), selection can eventually cleared clear_selection(). can create graph object add graph primitives paths, cycles, trees . can add one randomly generated graphs graph object. , let’s add directed GNM graph 10 nodes 15 edges (set_seed option makes random graph reproducible). undirected version graph can made using: can view graph using render_graph(). several layouts choose well (e.g., nicely, tree, kk, fr, etc.).","code":"a_graph <- create_graph() %>% add_node() %>% add_node() %>% add_edge(from = 1, to = 2) b_graph <- a_graph %>% delete_edge(from = 1, to = 2) c_graph <- b_graph %>% add_node(from = 1, to = 2) c_graph #> DiagrammeR Graph // 3 nodes / 2 edges #> -- directed / connected / DAG / simple #> #> NODES / type: / label: info: `get_node_df()` #> -- no additional node attributes #> EDGES / rel: info: `get_edge_df()` #> -- no additional edge attributes #> SELECTION / #> CACHE / #> GLOBAL ATTRS / 17 are set info: `get_global_graph_attr_info()` #> GRAPH ACTIONS / #> GRAPH LOG / <3 actions> -> add_edge() -> delete_edge() -> add_node() d_graph <- c_graph %>% add_node( type = \"type_a\", node_aes = node_aes( color = \"steelblue\", fillcolor = \"lightblue\", fontcolor = \"gray35\" ), node_data = node_data( value = 2.5 ) ) %>% add_edge( from = 1, to = 3, rel = \"interacted_with\", edge_aes = edge_aes( color = \"red\", arrowhead = \"vee\", tooltip = \"Red Arrow\" ), edge_data = edge_data( value = 5.2 ) ) e_graph <- d_graph %>% select_nodes(conditions = value == 2.5) %>% set_node_attrs_ws(node_attr = fillcolor, value = \"orange\") %>% clear_selection() f_graph <- create_graph() %>% add_path(n = 3) %>% add_cycle(n = 4) %>% add_balanced_tree(k = 2, h = 2) g_graph <- create_graph() %>% add_gnm_graph( n = 15, m = 20, set_seed = 23 ) h_graph <- create_graph(directed = FALSE) %>% add_gnm_graph( n = 15, m = 20, set_seed = 23 ) render_graph(h_graph, layout = \"fr\")"},{"path":"/index.html","id":"using-data-from-tables-to-generate-a-graph","dir":"","previous_headings":"","what":"Using Data from Tables to Generate a Graph","title":"Graph/Network Visualization","text":"DiagrammeR package contains simple datasets help illustrate create graph table data. node_list_1 edge_list_1 datasets super simple node edge data frames can assembled graph. Let’s print side side see ’re working . fashion graph, need ensure nodes attributes (case, just label) added, , edges added. Furthermore, must map definitions node id (cases, may need map relationships text labels text attribute stored node data frame). can use three functions generate graph containing data: create_graph() add_nodes_from_table() add_edges_from_table() Let’s show process stepwise fashion (occasionally viewing graph’s internal ndf edf) can understand actually happening. First, create graph object create_graph(): Add nodes table add_nodes_from_table(): Inspect graph’s internal node data frame (ndf) get_node_df(): graph now 10 nodes (edges yet). node automatically assigned auto-incrementing id. incoming id also automatically renamed id_external avoid duplicate column names also retain column mapping edge definitions. Now, let’s add edges. need specify from_col edge_list_1 table indeed to_col . from_to_map argument expects node attribute column columns map . case ’s id_external. Note id also matches perfectly mapping, may cases id won’t match id_external column (e.g., existing nodes node id values incoming table provided different order, etc.). Now, connect graph nodes edges another dataset using add_edges_from_table(): Inspect graph’s internal edge data frame (edf) get_edge_df(): supplying name graph object console, can get succinct summary graph’s properties. , see graph 10 nodes 19 edges: two similar datasets included package (node_list_2 edge_list_2). contain extended attribute data. Let’s quick look column names: unique labels label column, categorical labels type rel columns, can create property graph data. Like , can incorporate two tables graph add_nodes_from_table() add_edges_from_table(). time, ’ll remove auto-generated id_external node attribute drop_node_attrs() function. Let’s view graph summary console. Note additional node attributes (value_1 value_2) present nodes edges: Now, node/edge metadata (categorical labels numerical data value_1 & value_2 nodes edges), can interesting things graph. First, let’s mutation mutate_node_attrs() mutate_edge_attrs() get sums value_1 value_2 value_3 (nodes edges). , let’s color nodes edges forestgreen value_3 greater 10 (red otherwise). Finally, let’s display values value_3 nodes rendering graph diagram. go!","code":"node_list_1 edge_list_1 id label from to 1 1 A 1 1 2 2 2 B 2 1 3 3 3 C 3 1 4 4 4 D 4 1 9 5 5 E 5 2 8 6 6 F 6 2 7 7 7 G 7 2 1 8 8 H 8 2 10 9 9 I 9 3 1 10 10 J 10 3 6 11 3 8 12 4 1 13 5 7 14 6 2 15 6 9 16 8 1 17 9 3 18 9 10 19 10 1 # Create the graph object i_graph_1 <- create_graph() # It will start off as empty i_graph_1 %>% is_graph_empty() #> [1] TRUE # Add the nodes to the graph i_graph_2 <- i_graph_1 %>% add_nodes_from_table( table = node_list_1, label_col = label ) # View the graph's internal node data frame i_graph_2 %>% get_node_df() #> id type label id_external #> 1 1 A 1 #> 2 2 B 2 #> 3 3 C 3 #> 4 4 D 4 #> 5 5 E 5 #> 6 6 F 6 #> 7 7 G 7 #> 8 8 H 8 #> 9 9 I 9 #> 10 10 J 10 # Add the edges to the graph i_graph_3 <- i_graph_2 %>% add_edges_from_table( table = edge_list_1, from_col = from, to_col = to, from_to_map = id_external ) # View the edge data frame i_graph_3 %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 1 3 #> 3 3 1 4 #> 4 4 1 9 #> 5 5 2 8 #> 6 6 2 7 #> 7 7 2 1 #> 8 8 2 10 #> 9 9 3 1 #> 10 10 3 6 #> 11 11 3 8 #> 12 12 4 1 #> 13 13 5 7 #> 14 14 6 2 #> 15 15 6 9 #> 16 16 8 1 #> 17 17 9 3 #> 18 18 9 10 #> 19 19 10 1 i_graph_3 #> DiagrammeR Graph // 10 nodes / 19 edges #> -- directed / connected / simple #> #> NODES / type: / label: 10 vals - complete & unique #> -- 1 additional node attribute (id_external) #> EDGES / rel: info: `get_edge_df()` #> -- no additional edge attributes #> SELECTION / #> CACHE / #> GLOBAL ATTRS / 17 are set info: `get_global_graph_attr_info()` #> GRAPH ACTIONS / #> GRAPH LOG / <1 action> -> add_nodes_from_table() -> add_edges_from_table() -> () colnames(node_list_2) #> [1] \"id\" \"label\" \"type\" \"value_1\" \"value_2\" colnames(edge_list_2) #> [1] \"from\" \"to\" \"rel\" \"value_1\" \"value_2\" j_graph <- create_graph() %>% add_nodes_from_table( table = node_list_2, label_col = label, type_col = type ) %>% add_edges_from_table( table = edge_list_2, from_col = from, to_col = to, from_to_map = id_external, rel_col = rel ) %>% drop_node_attrs(node_attr = id_external) j_graph #> DiagrammeR Graph // 10 nodes / 19 edges #> -- directed / connected / property graph / simple #> #> NODES / type: 2 vals - complete / label: 10 vals - complete & unique #> -- 2 additional node attributes (value_1, value_2) #> EDGES / rel: 3 vals - complete info: `get_edge_df()` #> -- 2 additional edge attributes (value_1, value_2) #> SELECTION / #> CACHE / #> GLOBAL ATTRS / 17 are set info: `get_global_graph_attr_info()` #> GRAPH ACTIONS / #> GRAPH LOG / <3 actions> -> add_edges_from_table() -> () -> drop_node_attrs() k_graph <- j_graph %>% mutate_node_attrs(value_3 = value_1 + value_2) %>% mutate_edge_attrs(value_3 = value_1 + value_2) %>% select_nodes(conditions = value_3 > 10) %>% set_node_attrs_ws(node_attr = fillcolor, value = \"forestgreen\") %>% invert_selection() %>% set_node_attrs_ws(node_attr = fillcolor, value = \"red\") %>% select_edges(conditions = value_3 > 10) %>% set_edge_attrs_ws(edge_attr = color, value = \"forestgreen\") %>% invert_selection() %>% set_edge_attrs_ws(edge_attr = color, value = \"red\") %>% clear_selection() %>% set_node_attr_to_display(attr = value_3) render_graph(k_graph)"},{"path":"/index.html","id":"a-network-graph-example","dir":"","previous_headings":"","what":"A Network Graph Example","title":"Graph/Network Visualization","text":"Let’s create property graph pertains contributors three software projects. graph nodes representing people projects. attributes name, age, join_date, email, follower_count, following_count, starred_count specific person nodes project, start_date, stars, language attributes apply project nodes. edges represent relationships people project. example graph file repository.dgr available extdata/example_graphs_dgr/ directory DiagrammeR package (currently, GitHub version). can load memory using open_graph() function, system.file() helps provide location file within package. can always view property graph render_graph() function: Now graph set , can create queries magrittr pipelines get specific answers graph. Get average age contributors. Select nodes type person (project). node type non-NA age attribute, , get attribute vector get_node_attrs_ws() calculate mean R’s mean() function. can get total number commits projects. know edges contain numerical commits attribute, , select edges (select_edges() selects edges graph). , get numeric vector commits values get sum() (commits projects). Single one known Josh get total number commits maintainer contributor. Start selecting Josh node select_nodes(conditions = name == \"Josh\"). graph, know people edge project edge can relationship (rel) type contributor maintainer. can migrate selection nodes outbound edges trav_out_edges() (won’t provide condition, just outgoing edges Josh selected). Now selection 2 edges. Get vector commits values get_edge_attrs_ws() calculate sum(). total number commits. Get total number commits Louisa, just maintainer role though. case ’ll supply condition trav_out_edge(). acts filter traversal means selection applied edges condition met. Although single value, ’ll still use sum() get_edge_attrs_ws() (good practice may know vector length, especially big graphs). something complex, like, get names people graph age 32? First, select person nodes select_nodes(conditions = type == \"person\"). , follow another select_nodes() call specifying age > 32. Importantly, set_op = \"intersect\" (giving us intersection selections). Now starting selection nodes want, need get values nodes’ name attribute character vector. get_node_attrs_ws() function. getting vector, sort names alphabetically R function sort(). get named vector, can use unname() show us names vector component. supercalc project progressing quite nicely. Let’s get total number commits people interesting project. Start selecting project’s node work backwards. Traverse edges leading trav_in_edge(). edges committers contain commits attribute numerical values. Get vector commits get sum (1676 commits). Kim now contributor stringbuildeR project made 15 new commits project. can modify graph reflect . First, add edge add_edge(). Note add_edge() usually relies node IDs creating new edge. almost always inconvenient can instead use node labels (know unique graph) compose edge, setting use_labels = TRUE. rel value add_edge() set contributor – property graph always values set node type edge rel attributes. set another attribute edge (commits) first selecting edge (last edge made, can use select_last_edges_created()), , use set_edge_attrs_ws() provide attribute/value pair. Finally, clear active selections clear_selection(). graph now changed, look. Get email addresses contributors (maintainers) randomizer supercalc88 projects. trav_in_edge() just want contributer edges/commits. edges, hop back unconditionally people edges originate trav_out_node(). Get email values selected individuals sorted character vector. people committed one project? matter node degree. know people edges outward projects edges inward. Thus, anybody outdegree (number edges outward) greater 1 committed one project. Globally, select nodes condition using select_nodes_by_degree(\"outdeg > 1\"). getting name attribute values node selection, can provide sorted character vector names.","code":"# Load in a the small repository graph graph <- open_graph( system.file( \"extdata/example_graphs_dgr/repository.dgr\", package = \"DiagrammeR\" ) ) render_graph(graph, layout = \"kk\") graph %>% select_nodes(conditions = type == \"person\") %>% get_node_attrs_ws(node_attr = age) %>% mean() #> [1] 33.6 graph %>% select_edges() %>% get_edge_attrs_ws(edge_attr = commits) %>% sum() #> [1] 5182 graph %>% select_nodes(conditions = name == \"Josh\") %>% trav_out_edge() %>% get_edge_attrs_ws(edge_attr = commits) %>% sum() #> [1] 227 graph %>% select_nodes(conditions = name == \"Louisa\") %>% trav_out_edge(conditions = rel == \"maintainer\") %>% get_edge_attrs_ws(edge_attr = commits) %>% sum() #> [1] 236 graph %>% select_nodes(conditions = type == \"person\") %>% select_nodes(conditions = age > 32, set_op = \"intersect\") %>% get_node_attrs_ws(node_attr = name) %>% sort() %>% unname() #> [1] \"Jack\" \"Jon\" \"Kim\" \"Roger\" \"Sheryl\" graph %>% select_nodes(conditions = project == \"supercalc\") %>% trav_in_edge() %>% get_edge_attrs_ws(edge_attr = commits) %>% sum() #> [1] 1676 graph <- graph %>% add_edge( from = \"Kim\", to = \"stringbuildeR\", rel = \"contributor\" ) %>% select_last_edges_created() %>% set_edge_attrs_ws(edge_attr = commits, value = 15) %>% clear_selection() render_graph(graph, layout = \"kk\") graph %>% select_nodes( conditions = project == \"randomizer\" | project == \"supercalc\" ) %>% trav_in_edge(conditions = rel == \"contributor\") %>% trav_out_node() %>% get_node_attrs_ws(node_attr = email) %>% sort() %>% unname() #> [1] \"j_2000@ultramail.io\" \"josh_ch@megamail.kn\" #> [3] \"kim_3251323@ohhh.ai\" \"lhe99@mailing-fun.com\" #> [5] \"roger_that@whalemail.net\" \"the_simone@a-q-w-o.net\" #> [7] \"the_will@graphymail.com\" graph %>% select_nodes_by_degree(expressions = \"outdeg > 1\") %>% get_node_attrs_ws(node_attr = name) %>% sort() %>% unname() #> [1] \"Josh\" \"Kim\" \"Louisa\""},{"path":"/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Graph/Network Visualization","text":"DiagrammeR used R environment. don’t R installation, can obtained Comprehensive R Archive Network (CRAN). can install development version DiagrammeR GitHub using devtools package. , get CRAN. encounter bug, usage questions, want share ideas make package better, feel free file issue.","code":"devtools::install_github(\"rich-iannone/DiagrammeR\") install.packages(\"DiagrammeR\")"},{"path":"/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Graph/Network Visualization","text":"Please note DiagrammeR project released contributor code conduct.participating project agree abide terms.","code":""},{"path":"/index.html","id":"id_-license","dir":"","previous_headings":"","what":"📄 License","title":"Graph/Network Visualization","text":"DiagrammeR licensed MIT license. See LICENSE.md file details.","code":""},{"path":"/index.html","id":"id_️-governance","dir":"","previous_headings":"","what":"🏛️ Governance","title":"Graph/Network Visualization","text":"project primarily maintained Rich Iannone. authors may occasionally assist duties.","code":""},{"path":"/reference/DiagrammeR-package.html","id":null,"dir":"Reference","previous_headings":"","what":"DiagrammeR: Graph/Network Visualization — DiagrammeR-package","title":"DiagrammeR: Graph/Network Visualization — DiagrammeR-package","text":"Build graph/network structures using functions stepwise addition deletion nodes edges. Work data available tables bulk addition nodes, edges, associated metadata. Use graph selections traversals apply changes specific nodes edges. wide selection graph algorithms allow analysis graphs. Visualize graphs take advantage aesthetic properties assigned nodes edges.","code":""},{"path":[]},{"path":"/reference/DiagrammeR-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"DiagrammeR: Graph/Network Visualization — DiagrammeR-package","text":"Maintainer: Richard Iannone riannone@.com (ORCID) Authors: Olivier Roy olivierroy71@hotmail.com","code":""},{"path":"/reference/DiagrammeR.html","id":null,"dir":"Reference","previous_headings":"","what":"R + mermaid.js — DiagrammeR","title":"R + mermaid.js — DiagrammeR","text":"Make diagrams R using viz.js mermaid.js infrastructure provided htmlwidgets.","code":""},{"path":"/reference/DiagrammeR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"R + mermaid.js — DiagrammeR","text":"","code":"DiagrammeR(diagram = \"\", type = \"mermaid\", ...)"},{"path":"/reference/DiagrammeR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"R + mermaid.js — DiagrammeR","text":"diagram diagram graphviz mermaid format, , file (connection file name) containing diagram specification. recommended filename extensions .gv .mmd Graphviz mermaid diagram specifications, respectively. diagram provided (diagram = \"\") function assume diagram provided htmltools::tags() DiagrammeR just used dependency injection. type string, either mermaid (default) grViz indicating type diagram spec desired parser/renderer. ... parameters pass grViz mermaid","code":""},{"path":"/reference/DiagrammeR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"R + mermaid.js — DiagrammeR","text":"object class htmlwidget intelligently print HTML variety contexts including R console, within R Markdown documents, within Shiny output bindings.","code":""},{"path":"/reference/DiagrammeR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"R + mermaid.js — DiagrammeR","text":"","code":"if (FALSE) { # note the whitespace is not important DiagrammeR(\" graph LR A-->B A-->C C-->E B-->D C-->D D-->F E-->F \") DiagrammeR(\" graph TB A-->B A-->C C-->E B-->D C-->D D-->F E-->F \") DiagrammeR(\"graph LR;A(Rounded)-->B[Squared];B-->C{A Decision}; C-->D[Square One];C-->E[Square Two]; style A fill:#E5E25F; style B fill:#87AB51; style C fill:#3C8937; style D fill:#23772C; style E fill:#B6E6E6;\" ) # Load in the 'mtcars' dataset data(mtcars) connections <- sapply( 1:ncol(mtcars) ,function(i) { paste0( i ,\"(\",colnames(mtcars)[i],\")---\" ,i,\"-stats(\" ,paste0( names(summary(mtcars[,i])) ,\": \" ,unname(summary(mtcars[,i])) ,collapse=\"
    \" ) ,\")\" ) } ) DiagrammeR( paste0( \"graph TD;\", \"\\n\", paste(connections, collapse = \"\\n\"),\"\\n\", \"classDef column fill:#0001CC, stroke:#0D3FF3, stroke-width:1px;\" ,\"\\n\", \"class \", paste0(1:length(connections), collapse = \",\"), \" column;\" ) ) # also with DiagrammeR() you can use tags from htmltools # just make sure to use class = \"mermaid\" library(htmltools) diagramSpec = \" graph LR; id1(Start)-->id2(Stop); style id1 fill:#f9f,stroke:#333,stroke-width:4px; style id2 fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5; \" html_print(tagList( tags$h1(\"R + mermaid.js = Something Special\") ,tags$pre(diagramSpec) ,tags$div(class=\"mermaid\",diagramSpec) ,DiagrammeR() )) # sequence diagrams # Using this \"How to Draw a Sequence Diagram\" # http://www.cs.uku.fi/research/publications/reports/A-2003-1/page91.pdf # draw some sequence diagrams with DiagrammeR library(DiagrammeR) DiagrammeR(\" sequenceDiagram; customer->>ticket seller: ask for ticket; ticket seller->>database: seats; alt tickets available database->>ticket seller: ok; ticket seller->>customer: confirm; customer->>ticket seller: ok; ticket seller->>database: book a seat; ticket seller->>printer: print ticket; else sold out database->>ticket seller: none left; ticket seller->>customer: sorry; end \") }"},{"path":"/reference/DiagrammeROutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Widget output function for use in Shiny — DiagrammeROutput","title":"Widget output function for use in Shiny — DiagrammeROutput","text":"Widget output function use Shiny","code":""},{"path":"/reference/DiagrammeROutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Widget output function for use in Shiny — DiagrammeROutput","text":"","code":"DiagrammeROutput(outputId, width = \"100%\", height = \"auto\")"},{"path":"/reference/DiagrammeROutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Widget output function for use in Shiny — DiagrammeROutput","text":"outputId Output variable read width valid CSS unit width number, coerced string px appended. height valid CSS unit height number, coerced string px appended.","code":""},{"path":"/reference/add_balanced_tree.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a balanced tree to the graph — add_balanced_tree","title":"Add a balanced tree to the graph — add_balanced_tree","text":"graph object class dgr_graph, add balanced tree graph.","code":""},{"path":"/reference/add_balanced_tree.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a balanced tree to the graph — add_balanced_tree","text":"","code":"add_balanced_tree( graph, k, h, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_balanced_tree.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a balanced tree to the graph — add_balanced_tree","text":"graph graph object class dgr_graph. k branching factor tree. h height tree. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , boolean value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node tree. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_balanced_tree.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a balanced tree to the graph — add_balanced_tree","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_balanced_tree.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a balanced tree to the graph — add_balanced_tree","text":"","code":"# Create a new graph and # add 2 different types of # balanced trees of height # 2 (branching twice) and # different branching ratios graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2, type = \"binary\") %>% add_balanced_tree( k = 3, h = 2, type = \"tertiary\") # Get some node information # from this graph graph %>% get_node_info() %>% head(5) #> id type label deg indeg outdeg loops #> 1 1 binary 1 2 0 2 0 #> 2 2 binary 2 3 1 2 0 #> 3 3 binary 3 3 1 2 0 #> 4 4 binary 4 1 1 0 0 #> 5 5 binary 5 1 1 0 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments graph_w_attrs <- create_graph() %>% add_balanced_tree( k = 2, h = 2, label = c( \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\"), type = c( \"a\", \"b\", \"b\", \"c\", \"c\", \"c\", \"c\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), node_data = node_data( value = c( 1.6, 2.8, 3.4, 8.3, 3.8, 5.2, 3.2)), edge_aes = edge_aes( color = \"red\", penwidth = 1.2)) # Get the first three rows of # the graph's node data frame graph_w_attrs %>% get_node_df() %>% head(3) #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 b two steelblue 2.8 #> 3 3 b three steelblue 3.4 # Get the first three rows of # the graph's edge data frame graph_w_attrs %>% get_edge_df() %>% head(3) #> id from to rel penwidth color #> 1 1 1 2 A 1.2 red #> 2 2 1 3 A 1.2 red #> 3 3 2 4 A 1.2 red"},{"path":"/reference/add_cycle.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a cycle of nodes to the graph — add_cycle","title":"Add a cycle of nodes to the graph — add_cycle","text":"graph object class dgr_graph, add node cycle graph.","code":""},{"path":"/reference/add_cycle.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a cycle of nodes to the graph — add_cycle","text":"","code":"add_cycle( graph, n, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_cycle.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a cycle of nodes to the graph — add_cycle","text":"graph graph object class dgr_graph. n number nodes comprising cycle. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , boolean value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node cycle. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_cycle.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a cycle of nodes to the graph — add_cycle","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_cycle.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a cycle of nodes to the graph — add_cycle","text":"","code":"# Create a new graph and # add a cycle of nodes to it graph <- create_graph() %>% add_cycle(n = 6) # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 1 2 1 1 0 #> 2 2 2 2 1 1 0 #> 3 3 3 2 1 1 0 #> 4 4 4 2 1 1 0 #> 5 5 5 2 1 1 0 #> 6 6 6 2 1 1 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) graph_w_attrs <- create_graph() %>% add_cycle( n = 3, label = c( \"one\", \"two\", \"three\"), type = c( \"a\", \"a\", \"b\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), edge_aes = edge_aes( color = \"red\", penwidth = 1.2), node_data = node_data( value = c( 1.6, 2.8, 3.4)), edge_data = edge_data( value = rnorm( n = 3, mean = 5.0, sd = 1.0))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 a two steelblue 2.8 #> 3 3 b three steelblue 3.4 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 A 1.2 red 5.996605 #> 2 2 2 3 A 1.2 red 6.107490 #> 3 3 3 1 A 1.2 red 4.721914"},{"path":"/reference/add_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Add an edge between nodes in a graph object — add_edge","title":"Add an edge between nodes in a graph object — add_edge","text":"graph object class dgr_graph, add edge nodes within graph.","code":""},{"path":"/reference/add_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add an edge between nodes in a graph object — add_edge","text":"","code":"add_edge(graph, from, to, rel = NULL, edge_aes = NULL, edge_data = NULL)"},{"path":"/reference/add_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add an edge between nodes in a graph object — add_edge","text":"graph graph object class dgr_graph. outgoing node edge connected. option use node label value (must correspondingly also done argument) defining node connections. Note possible nodes distinct label values set none exist empty string. incoming nodes edge connected. option use node label value (must correspondingly also done argument) defining node connections. Note possible nodes distinct label values set none exist empty string. rel optional string specifying relationship connected nodes. edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add an edge between nodes in a graph object — add_edge","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add an edge between nodes in a graph object — add_edge","text":"","code":"# Create a graph with 4 nodes graph <- create_graph() %>% add_node(label = \"one\") %>% add_node(label = \"two\") %>% add_node(label = \"three\") %>% add_node(label = \"four\") # Add an edge between those # nodes and attach a # relationship to the edge graph <- add_edge( graph, from = 1, to = 2, rel = \"A\") # Use the `get_edge_info()` # function to verify that # the edge has been created graph %>% get_edge_info() #> id from to rel #> 1 1 1 2 A # Add another node and # edge to the graph graph <- graph %>% add_edge( from = 3, to = 2, rel = \"A\") # Verify that the edge # has been created by # counting graph edges graph %>% count_edges() #> [1] 2 # Add edges by specifying # node `label` values; note # that all nodes must have # unique `label` values to # use this option graph <- graph %>% add_edge( from = \"three\", to = \"four\", rel = \"L\") %>% add_edge( from = \"four\", to = \"one\", rel = \"L\") # Use `get_edges()` to verify # that the edges were added graph %>% get_edges() #> [1] \"1->2\" \"3->2\" \"3->4\" \"4->1\" # Add edge aesthetic and data # attributes during edge creation graph_2 <- create_graph() %>% add_n_nodes(n = 2) %>% add_edge( from = 1, to = 2, rel = \"M\", edge_aes = edge_aes( penwidth = 1.5, color = \"blue\"), edge_data = edge_data( value = 4.3)) # Use the `get_edges()` function # to verify that the attribute # values were bound to the # newly created edge graph_2 %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 M 1.5 blue 4.3"},{"path":"/reference/add_edge_clone.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a clone of an existing edge to the graph — add_edge_clone","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"Add new edge graph object class dgr_graph clone edge already graph. edge attributes preserved.","code":""},{"path":"/reference/add_edge_clone.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"","code":"add_edge_clone(graph, edge, from, to)"},{"path":"/reference/add_edge_clone.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"graph graph object class dgr_graph. edge edge ID corresponding graph edge cloned. outgoing node edge connected. incoming nodes edge connected.","code":""},{"path":"/reference/add_edge_clone.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edge_clone.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a clone of an existing edge to the graph — add_edge_clone","text":"","code":"# Create a graph with a path of # 2 nodes; supply a common `rel` # edge attribute for all edges # in this path and then add a # `color` edge attribute graph <- create_graph() %>% add_path( n = 2, rel = \"a\") %>% select_last_edges_created() %>% set_edge_attrs( edge_attr = color, values = \"steelblue\") %>% clear_selection() # Display the graph's internal # edge data frame graph %>% get_edge_df() #> id from to rel color #> 1 1 1 2 a steelblue # Create a new node (will have # node ID of `3`) and then # create an edge between it and # node `1` while reusing the edge # attributes of edge `1` -> `2` # (edge ID `1`) graph_2 <- graph %>% add_node() %>% add_edge_clone( edge = 1, from = 3, to = 1) # Display the graph's internal # edge data frame graph_2 %>% get_edge_df() #> id from to rel color #> 1 1 1 2 a steelblue #> 2 2 3 1 a steelblue # The same change can be performed # with some helper functions in the # `add_edge_clone()` function call graph_3 <- graph %>% add_node() %>% add_edge_clone( edge = get_last_edges_created(.), from = get_last_nodes_created(.), to = 1) # Display the graph's internal # edge data frame graph_3 %>% get_edge_df() #> id from to rel color #> 1 1 1 2 a steelblue #> 2 2 3 1 a steelblue"},{"path":"/reference/add_edge_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Add edges from an edge data frame to an existing graph object — add_edge_df","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"graph object class dgr_graph, add edges edge data frame graph.","code":""},{"path":"/reference/add_edge_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"","code":"add_edge_df(graph, edge_df)"},{"path":"/reference/add_edge_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"graph graph object class dgr_graph. edge_df edge data frame created using create_edge_df().","code":""},{"path":"/reference/add_edge_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edge_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add edges from an edge data frame to an existing graph object — add_edge_df","text":"","code":"# Create a graph with 4 nodes # and no edges graph <- create_graph() %>% add_n_nodes(n = 4) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1)) # Add the edge data frame to # the graph object to create # a graph with both nodes # and edges graph <- graph %>% add_edge_df( edge_df = edf) # Get the graph's edges to # verify that the edf had # been added graph %>% get_edges( return_type = \"vector\") #> [1] \"1->4\" \"2->3\" \"3->1\""},{"path":"/reference/add_edges_from_table.html","id":null,"dir":"Reference","previous_headings":"","what":"Add edges and attributes to graph from a table — add_edges_from_table","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"Add edges attributes existing graph object data CSV file data frame.","code":""},{"path":"/reference/add_edges_from_table.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"","code":"add_edges_from_table( graph, table, from_col, to_col, from_to_map, rel_col = NULL, set_rel = NULL, drop_cols = NULL )"},{"path":"/reference/add_edges_from_table.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"graph graph object class dgr_graph. table Either path CSV file, , data frame object. from_col name table column edges originate. to_col name table column edges terminate. from_to_map single character value mapping columns external table (supplied from_col to_col, respectively) column graph's internal node data frame (ndf). rel_col option apply column data table rel attribute values. set_rel optional string apply rel attribute edges created table records. drop_cols optional column selection statement dropping columns external table inclusion attributes graph's internal edge data frame. Several columns can dropped name using syntax col_1 & col_2 & .... Columns can also dropped using numeric column range : (e.g., 5:8), , using : column names specify range (e.g., col_5_name:col_8_name).","code":""},{"path":"/reference/add_edges_from_table.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edges_from_table.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add edges and attributes to graph from a table — add_edges_from_table","text":"","code":"# Create an empty graph and then # add nodes to it from the # `currencies` dataset available # in the package graph <- create_graph() %>% add_nodes_from_table( table = currencies) # Now we want to add edges to the # graph using an included dataset, # `usd_exchange_rates`, which has # exchange rates between USD and # many other currencies; the key # here is that the data in the # `from` and `to` columns in the # external table maps to graph # node data available in the # `iso_4217_code` column of the # graph's internal node data frame graph_1 <- graph %>% add_edges_from_table( table = usd_exchange_rates, from_col = from_currency, to_col = to_currency, from_to_map = iso_4217_code) # View part of the graph's # internal edge data frame graph_1 %>% get_edge_df() %>% head() #> id from to rel cost_unit #> 1 1 148 1 0.272300 #> 2 2 148 2 0.015210 #> 3 3 148 3 0.008055 #> 4 4 148 4 0.002107 #> 5 5 148 5 0.565000 #> 6 6 148 6 0.006058 # If you would like to assign # any of the table's columns as the # `rel` attribute, this can done # with the `rel_col` argument; to # set a static `rel` attribute for # all edges created, use `set_rel` graph_2 <- graph %>% add_edges_from_table( table = usd_exchange_rates, from_col = from_currency, to_col = to_currency, from_to_map = iso_4217_code, set_rel = \"from_usd\") # View part of the graph's internal # edge data frame (edf) graph_2 %>% get_edge_df() %>% head() #> id from to rel cost_unit #> 1 1 148 1 from_usd 0.272300 #> 2 2 148 2 from_usd 0.015210 #> 3 3 148 3 from_usd 0.008055 #> 4 4 148 4 from_usd 0.002107 #> 5 5 148 5 from_usd 0.565000 #> 6 6 148 6 from_usd 0.006058"},{"path":"/reference/add_edges_w_string.html","id":null,"dir":"Reference","previous_headings":"","what":"Add one or more edges using a text string — add_edges_w_string","title":"Add one or more edges using a text string — add_edges_w_string","text":"graph object class dgr_graph, add one edges graph using text string.","code":""},{"path":"/reference/add_edges_w_string.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add one or more edges using a text string — add_edges_w_string","text":"","code":"add_edges_w_string(graph, edges, rel = NULL, use_labels = FALSE)"},{"path":"/reference/add_edges_w_string.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add one or more edges using a text string — add_edges_w_string","text":"graph graph object class dgr_graph. edges single-length vector character string specifying edges. directed graph, string object formatted series node ID values [node_ID_1]->[node_ID_2] separated one space characters. undirected graphs, -- replace ->. Line breaks vector cause error. rel optional vector specifying relationship connected nodes. use_labels option use node label values edges string define node connections. Note possible nodes distinct label values set none exist empty string.","code":""},{"path":"/reference/add_edges_w_string.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add one or more edges using a text string — add_edges_w_string","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_edges_w_string.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add one or more edges using a text string — add_edges_w_string","text":"","code":"# Create a graph with 4 nodes graph <- create_graph() %>% add_node(label = \"one\") %>% add_node(label = \"two\") %>% add_node(label = \"three\") %>% add_node(label = \"four\") # Add edges between nodes using # a character string with node # ID values graph_node_id <- graph %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->3\") # Show the graph's internal # edge data frame graph_node_id %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 1 3 #> 3 3 2 4 #> 4 4 2 3 # Add edges between nodes using # a character string with node # label values and setting # `use_labels = TRUE`; note that # all nodes must have unique # `label` values to use this graph_node_label <- graph %>% add_edges_w_string( edges = \"one->two one->three two->four two->three\", use_labels = TRUE) # Show the graph's internal # edge data frame (it's the # same as before) graph_node_label %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 1 3 #> 3 3 2 4 #> 4 4 2 3 "},{"path":"/reference/add_forward_edges_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"Add edges direction one edges available edge selection graph object class dgr_graph. New graph edges edge definitions selection except new edge ID values. also option assign common rel grouping newly created edges. Upon addition edges, edge selection retained selection traversal operations. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/add_forward_edges_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"","code":"add_forward_edges_ws(graph, rel = NULL)"},{"path":"/reference/add_forward_edges_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"graph graph object class dgr_graph. rel optional string apply rel attribute newly created edges.","code":""},{"path":"/reference/add_forward_edges_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_forward_edges_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add new edges with identical definitions as with a selection of edges — add_forward_edges_ws","text":"","code":"# Create an empty graph, add 2 nodes # to it, and create the edge `1->2` graph <- create_graph() %>% add_n_nodes( n = 2, type = \"type_a\", label = c(\"a_1\", \"a_2\")) %>% add_edge( from = 1, to = 2, rel = \"a\") # Get the graph's edges graph %>% get_edge_ids() #> [1] 1 # Select the edge and create 2 # additional edges with the same # definition (`1->2`) but with # different `rel` values (`b` and `c`) graph <- graph %>% select_edges() %>% add_forward_edges_ws(rel = \"b\") %>% add_forward_edges_ws(rel = \"c\") %>% clear_selection() # Get the graph's edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 a #> 2 2 1 2 b #> 3 3 1 2 c"},{"path":"/reference/add_full_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a fully connected graph — add_full_graph","title":"Add a fully connected graph — add_full_graph","text":"graph object class dgr_graph, add fully connected graph either without loops. graph object set directed, added graph edges pair nodes. undirected case, single edge link pair nodes.","code":""},{"path":"/reference/add_full_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a fully connected graph — add_full_graph","text":"","code":"add_full_graph( graph, n, type = NULL, label = TRUE, rel = NULL, edge_wt_matrix = NULL, keep_loops = FALSE, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_full_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a fully connected graph — add_full_graph","text":"graph graph object class dgr_graph. n number nodes comprising fully connected graph. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , boolean value setting TRUE ascribes node IDs label FALSE NULL yields blank label. rel optional string providing relationship label new edges created connected graph. edge_wt_matrix optional matrix n n dimensions containing values apply edge weights. matrix row names column names label = TRUE, row column names used node label values. keep_loops option simplify fully connected graph removing loops (edges node). default value FALSE. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_full_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a fully connected graph — add_full_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_full_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a fully connected graph — add_full_graph","text":"","code":"# Create a new graph object # and add a directed and fully # connected graph with 3 nodes # and edges to and from all # pairs of nodes; with the option # `keep_loops = TRUE` nodes # will also have edges from # and to themselves graph <- create_graph() %>% add_full_graph( n = 3, keep_loops = TRUE ) # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 1 6 3 3 1 #> 2 2 2 6 3 3 1 #> 3 3 3 6 3 3 1 # Using `keep_loops = FALSE` # (the default) will remove # the loops create_graph() %>% add_full_graph(n = 3) %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 1 4 2 2 0 #> 2 2 2 4 2 2 0 #> 3 3 3 4 2 2 0 # Values can be set for # the node `label`, node # `type`, and edge `rel` graph <- create_graph() %>% add_full_graph( n = 3, type = \"connected\", label = c(\"1st\", \"2nd\", \"3rd\"), rel = \"connected_to\" ) # Show the graph's node # data frame (ndf) graph %>% get_node_df() #> id type label #> 1 1 connected 1st #> 2 2 connected 2nd #> 3 3 connected 3rd # Show the graph's edge # data frame (edf) graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 connected_to #> 2 2 1 3 connected_to #> 3 3 2 1 connected_to #> 4 4 2 3 connected_to #> 5 5 3 1 connected_to #> 6 6 3 2 connected_to # Create a fully-connected and # directed graph with 3 nodes, # and, where a matrix provides # edge weights; first, create the # matrix (with row names to be # used as node labels) suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) edge_wt_matrix <- rnorm(100, 5, 2) %>% sample(9, FALSE) %>% round(2) %>% matrix( ncol = 3, nrow = 3, dimnames = list(c(\"a\", \"b\", \"c\")) ) # Create the fully-connected # graph (without loops however) graph <- create_graph() %>% add_full_graph( n = 3, type = \"weighted\", label = TRUE, rel = \"related_to\", edge_wt_matrix = edge_wt_matrix, keep_loops = FALSE) # Show the graph's node # data frame (ndf) graph %>% get_node_df() #> id type label #> 1 1 weighted a #> 2 2 weighted b #> 3 3 weighted c # Show the graph's edge # data frame (edf) graph %>% get_edge_df() #> id from to rel weight #> 1 1 1 2 related_to 3.30 #> 2 2 1 3 related_to 5.02 #> 3 3 2 1 related_to 4.13 #> 4 4 2 3 related_to 6.49 #> 5 5 3 1 related_to 6.03 #> 6 6 3 2 related_to 5.55 # An undirected graph can # also use a matrix with # edge weights, but only # the lower triangle of # that matrix will be used create_graph(directed = FALSE) %>% add_full_graph( n = 3, type = \"weighted\", label = TRUE, rel = \"related_to\", edge_wt_matrix = edge_wt_matrix, keep_loops = FALSE ) %>% get_edge_df() #> id from to rel weight #> 1 1 1 2 related_to 3.30 #> 2 2 1 3 related_to 5.02 #> 3 3 2 3 related_to 6.49"},{"path":"/reference/add_global_graph_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Add one or more global graph attributes — add_global_graph_attrs","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"Add global attributes specific type (either graph_attrs, node_attrs, edge_attrs graph object class dgr_graph).","code":""},{"path":"/reference/add_global_graph_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"","code":"add_global_graph_attrs(graph, attr, value, attr_type)"},{"path":"/reference/add_global_graph_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"graph graph object class dgr_graph. attr name attribute set type global attribute specified. value value set chosen attribute specified attr_for_type argument. attr_type specific type global graph attribute set. type specified graph, node, edge.","code":""},{"path":"/reference/add_global_graph_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_global_graph_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add one or more global graph attributes — add_global_graph_attrs","text":"","code":"# Create a new graph with no # global graph attributes and # add a global graph attribute graph <- create_graph( attr_theme = NULL) %>% add_global_graph_attrs( attr = \"overlap\", value = \"true\", attr_type = \"graph\") # Verify that the attribute # addition has been made graph %>% get_global_graph_attr_info() #> # A tibble: 1 × 3 #> attr value attr_type #> #> 1 overlap true graph # Add another attribute with # `add_global_graph_attrs()` graph <- graph %>% add_global_graph_attrs( attr = \"penwidth\", value = 12, attr_type = \"node\") # Verify that the attribute # addition has been made graph %>% get_global_graph_attr_info() #> # A tibble: 2 × 3 #> attr value attr_type #> #> 1 overlap true graph #> 2 penwidth 12 node # When adding an attribute where # `attr` and `attr_type` already # exists, the value provided will # serve as an update graph %>% add_global_graph_attrs( attr = \"penwidth\", value = 15, attr_type = \"node\") %>% get_global_graph_attr_info() #> # A tibble: 2 × 3 #> attr value attr_type #> #> 1 overlap true graph #> 2 penwidth 15 node"},{"path":"/reference/add_gnm_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"existing graph object, add graph built according Erdos-Renyi G(n, m) model. uses constant probability creating fixed number edges. Thus n nodes m edges , loops argument set TRUE, random loop edges part m.","code":""},{"path":"/reference/add_gnm_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"","code":"add_gnm_graph( graph, n, m, loops = FALSE, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_gnm_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"graph graph object class dgr_graph. n number nodes comprising generated graph. m number edges generated graph. loops logical value (default FALSE) governs whether loops allowed created. type optional string describes entity type nodes added. label boolean value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_gnm_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_gnm_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a G(n, m) Erdos-Renyi graph — add_gnm_graph","text":"","code":"# Create an undirected GNM # graph with 100 nodes and # 120 edges gnm_graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 100, m = 120) # Get a count of nodes gnm_graph %>% count_nodes() #> [1] 100 # Get a count of edges gnm_graph %>% count_edges() #> [1] 120"},{"path":"/reference/add_gnp_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"existing graph object, add graph built according Erdos-Renyi G(n, p) model, uses constant probability creating edges.","code":""},{"path":"/reference/add_gnp_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"","code":"add_gnp_graph( graph, n, p, loops = FALSE, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_gnp_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"graph graph object class dgr_graph. n number nodes comprising generated graph. p probability creating edge two arbitrary nodes. loops logical value (default FALSE) governs whether loops allowed created. type optional string describes entity type nodes added. label boolean value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_gnp_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_gnp_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a G(n, p) Erdos-Renyi graph — add_gnp_graph","text":"","code":"# Create an undirected GNP # graph with 100 nodes using # a probability value of 0.05 gnp_graph <- create_graph( directed = FALSE) %>% add_gnp_graph( n = 100, p = 0.05) # Get a count of nodes gnp_graph %>% count_nodes() #> [1] 100 # Get a count of edges gnp_graph %>% count_edges() #> [1] 212"},{"path":"/reference/add_graph_action.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a graph action for execution at every transform — add_graph_action","title":"Add a graph action for execution at every transform — add_graph_action","text":"Add graph function along arguments run every graph transformation step.","code":""},{"path":"/reference/add_graph_action.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a graph action for execution at every transform — add_graph_action","text":"","code":"add_graph_action(graph, fcn, ..., action_name = NULL)"},{"path":"/reference/add_graph_action.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a graph action for execution at every transform — add_graph_action","text":"graph graph object class dgr_graph. fcn name function use. ... Arguments values pass named function fcn, necessary. action_name optional name labeling action.","code":""},{"path":"/reference/add_graph_action.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a graph action for execution at every transform — add_graph_action","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_graph_action.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a graph action for execution at every transform — add_graph_action","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 22, set_seed = 23) # Add a graph action that sets a node # attr column with a function; the # main function `set_node_attr_w_fcn()` # uses the `get_betweenness()` function # to provide betweenness values in the # `btwns` column; this action will # occur whenever there is a function # called on the graph that modifies it # (e.g., `add_n_nodes()`) graph <- graph %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_betweenness\", column_name = \"btwns\", action_name = \"get_btwns\") # To ensure that the action is # available in the graph, use the # `get_graph_actions()` function graph %>% get_graph_actions() #> # A tibble: 1 × 3 #> action_index action_name expression #> #> 1 1 get_btwns set_node_attr_w_fcn(graph = graph, node_attr_fcn = '…"},{"path":"/reference/add_graph_to_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Add graph object to a graph series object — add_graph_to_graph_series","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"Add graph object extant graph series object storage multiple graphs across sequential temporal one-dimensional array.","code":""},{"path":"/reference/add_graph_to_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"","code":"add_graph_to_graph_series(graph_series, graph)"},{"path":"/reference/add_graph_to_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"graph_series graph series object graph object added. graph graph object add graph series object.","code":""},{"path":"/reference/add_graph_to_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"graph series object type dgr_graph_1D.","code":""},{"path":"/reference/add_graph_to_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add graph object to a graph series object — add_graph_to_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Count the number of graphs # in the graph series series %>% count_graphs_in_graph_series() #> [1] 3"},{"path":"/reference/add_grid_2d.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a 2D grid of nodes to the graph — add_grid_2d","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"graph object class dgr_graph, add two-dimensional grid graph.","code":""},{"path":"/reference/add_grid_2d.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"","code":"add_grid_2d( graph, x, y, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_grid_2d.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"graph graph object class dgr_graph. x number nodes x direction. y number nodes y direction. type optional string describes entity type nodes added. label Either vector object length x * y provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created grid. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_grid_2d.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_grid_2d.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a 2D grid of nodes to the graph — add_grid_2d","text":"","code":"# Create a new graph and add # a 3 x 3 grid graph <- create_graph() %>% add_grid_2d( x = 3, y = 3, type = \"grid\") # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 grid 1 2 0 2 0 #> 2 2 grid 2 3 1 2 0 #> 3 3 grid 3 2 1 1 0 #> 4 4 grid 4 3 1 2 0 #> 5 5 grid 5 4 2 2 0 #> 6 6 grid 6 3 2 1 0 #> 7 7 grid 7 2 1 1 0 #> 8 8 grid 8 3 2 1 0 #> 9 9 grid 9 2 2 0 0 # Attributes can be specified # in extra arguments and these # are applied in order; Usually # these attributes are applied # to nodes (e.g., `type` is a # node attribute) but the `rel` # attribute will apply to the # edges graph_w_attrs <- create_graph() %>% add_grid_2d( x = 3, y = 2, label = c(\"one\", \"two\", \"three\", \"four\", \"five\", \"six\"), type = c(\"a\", \"a\", \"b\", \"b\", \"c\", \"c\"), rel = \"grid\", node_data = node_data( value = c( 1.2, 8.4, 3.4, 5.2, 6.1, 2.6))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label value #> 1 1 a one 1.2 #> 2 2 a two 8.4 #> 3 3 b three 3.4 #> 4 4 b four 5.2 #> 5 5 c five 6.1 #> 6 6 c six 2.6 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel #> 1 1 1 2 grid #> 2 2 1 4 grid #> 3 3 2 3 grid #> 4 4 2 5 grid #> 5 5 3 6 grid #> 6 6 4 5 grid #> 7 7 5 6 grid"},{"path":"/reference/add_grid_3d.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a 3D grid of nodes to the graph — add_grid_3d","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"graph object class dgr_graph, add three-dimensional grid graph.","code":""},{"path":"/reference/add_grid_3d.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"","code":"add_grid_3d( graph, x, y, z, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_grid_3d.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"graph graph object class dgr_graph. x number nodes x direction. y number nodes y direction. z number nodes z direction. type optional string describes entity type nodes added. label Either vector object length x * y * z provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created grid. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_grid_3d.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_grid_3d.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a 3D grid of nodes to the graph — add_grid_3d","text":"","code":"# Create a new graph and add # a 2 x 2 x 2 grid graph <- create_graph() %>% add_grid_3d( x = 2, y = 2, z = 2, type = \"grid\") # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 grid 1 3 0 3 0 #> 2 2 grid 2 3 1 2 0 #> 3 3 grid 3 3 1 2 0 #> 4 4 grid 4 3 2 1 0 #> 5 5 grid 5 3 1 2 0 #> 6 6 grid 6 3 2 1 0 #> 7 7 grid 7 3 2 1 0 #> 8 8 grid 8 3 3 0 0 # Attributes can be specified # in extra arguments and these # are applied in order; Usually # these attributes are applied # to nodes (e.g., `type` is a # node attribute) but the `rel` # attribute will apply to the # edges graph_w_attrs <- create_graph() %>% add_grid_3d( x = 2, y = 2, z = 2, label = c( \"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\"), type = c( \"a\", \"a\", \"b\", \"b\", \"c\", \"c\", \"d\", \"d\"), rel = \"grid\", node_data = node_data( value = c( 1.2, 8.4, 3.4, 5.2, 6.1, 2.6, 6.3, 9.3))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label value #> 1 1 a one 1.2 #> 2 2 a two 8.4 #> 3 3 b three 3.4 #> 4 4 b four 5.2 #> 5 5 c five 6.1 #> 6 6 c six 2.6 #> 7 7 d seven 6.3 #> 8 8 d eight 9.3 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel #> 1 1 1 2 grid #> 2 2 1 3 grid #> 3 3 1 5 grid #> 4 4 2 4 grid #> 5 5 2 6 grid #> 6 6 3 4 grid #> 7 7 3 7 grid #> 8 8 4 8 grid #> 9 9 5 6 grid #> 10 10 5 7 grid #> 11 11 6 8 grid #> 12 12 7 8 grid"},{"path":"/reference/add_growing_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a random growing graph with m edges added per step — add_growing_graph","title":"Create a random growing graph with m edges added per step — add_growing_graph","text":"existing graph object, add graph built adding m new edges time step (node added).","code":""},{"path":"/reference/add_growing_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a random growing graph with m edges added per step — add_growing_graph","text":"","code":"add_growing_graph( graph, n, m = 1, citation = FALSE, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_growing_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a random growing graph with m edges added per step — add_growing_graph","text":"graph graph object class dgr_graph. n number nodes comprising generated graph. m number edges added per time step. citation logical value (default FALSE) governs whether citation graph created. new edges specifically originate newly added node recent time step. type optional string describes entity type nodes added. label logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_growing_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a random growing graph with m edges added per step — add_growing_graph","text":"","code":"# Create a random, growing # citation graph with 100 # nodes, adding an edge after # each node addition growing_graph <- create_graph() %>% add_growing_graph( n = 100, m = 1, citation = TRUE, set_seed = 23) # Get a count of nodes growing_graph %>% count_nodes() #> [1] 100 # Get a count of edges growing_graph %>% count_edges() #> [1] 99"},{"path":"/reference/add_islands_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a random islands graph with edges between the islands — add_islands_graph","title":"Create a random islands graph with edges between the islands — add_islands_graph","text":"existing graph object, add several Erdos-Renyi random graphs (islands) using common set parameters, connected together fixed number edges.","code":""},{"path":"/reference/add_islands_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a random islands graph with edges between the islands — add_islands_graph","text":"","code":"add_islands_graph( graph, n_islands, island_size, p, edges_between, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_islands_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a random islands graph with edges between the islands — add_islands_graph","text":"graph graph object class dgr_graph. n_islands number islands generated graph. island_size size islands generated graph. p probability edges islands. edges_between number edges islands. type optional string describes entity type nodes added. label logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_islands_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a random islands graph with edges between the islands — add_islands_graph","text":"","code":"# Create a graph of islands islands_graph <- create_graph() %>% add_islands_graph( n_islands = 4, island_size = 10, p = 0.5, edges_between = 1, set_seed = 23) # Get a count of nodes islands_graph %>% count_nodes() #> [1] 40 # Get a count of edges islands_graph %>% count_edges() #> [1] 98"},{"path":"/reference/add_mathjax.html","id":null,"dir":"Reference","previous_headings":"","what":"Add MathJax-formatted equation text — add_mathjax","title":"Add MathJax-formatted equation text — add_mathjax","text":"Add MathJax-formatted equation text","code":""},{"path":"/reference/add_mathjax.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add MathJax-formatted equation text — add_mathjax","text":"","code":"add_mathjax(gv = NULL, include_mathjax = TRUE)"},{"path":"/reference/add_mathjax.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add MathJax-formatted equation text — add_mathjax","text":"gv grViz htmlwidget. include_mathjax logical add mathjax JS. Change FALSE using rmarkdown since MathJax likely already added.","code":""},{"path":"/reference/add_mathjax.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add MathJax-formatted equation text — add_mathjax","text":"grViz htmlwidget","code":""},{"path":"/reference/add_n_node_clones.html","id":null,"dir":"Reference","previous_headings":"","what":"Add one or several clones of an existing node to the graph — add_n_node_clones","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"Add n new nodes graph object class dgr_graph clones node already graph. node attributes preserved except node label attribute (maintain uniqueness non-NA node label values). vector node label can provided bind new labels cloned nodes.","code":""},{"path":"/reference/add_n_node_clones.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"","code":"add_n_node_clones(graph, n, node, label = NULL)"},{"path":"/reference/add_n_node_clones.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"graph graph object class dgr_graph. n number node clones add graph. node node ID corresponding graph node cloned. label optional vector node label values. vector length correspond value set n.","code":""},{"path":"/reference/add_n_node_clones.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_n_node_clones.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add one or several clones of an existing node to the graph — add_n_node_clones","text":"","code":"# Create a graph with a path of # nodes; supply `label`, `type`, # and `value` node attributes graph <- create_graph() %>% add_path( n = 3, label = c(\"d\", \"g\", \"r\"), type = c(\"a\", \"b\", \"c\")) # Display the graph's internal # node data frame graph %>% get_node_df() #> id type label #> 1 1 a d #> 2 2 b g #> 3 3 c r # Create 3 clones of node `1` # but assign new node label # values (leaving `label` as # NULL yields NA values) graph <- graph %>% add_n_node_clones( n = 3, node = 1, label = c(\"x\", \"y\", \"z\")) # Display the graph's internal # node data frame: nodes `4`, # `5`, and `6` are clones of `1` graph %>% get_node_df() #> id type label #> 1 1 a d #> 2 2 b g #> 3 3 c r #> 4 4 a x #> 5 5 a y #> 6 6 a z"},{"path":"/reference/add_n_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Add one or several unconnected nodes to the graph — add_n_nodes","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"Add n new nodes graph object class dgr_graph. Optionally, set node type values new nodes.","code":""},{"path":"/reference/add_n_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"","code":"add_n_nodes( graph, n, type = NULL, label = NULL, node_aes = NULL, node_data = NULL )"},{"path":"/reference/add_n_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"graph graph object class dgr_graph. n number new nodes add graph. type optional character vector provides group identifiers nodes added. label optional character object describes nodes added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes.","code":""},{"path":"/reference/add_n_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_n_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add one or several unconnected nodes to the graph — add_n_nodes","text":"","code":"# Create an empty graph and # add 5 nodes; these nodes # will be assigned ID values # from `1` to `5` graph <- create_graph() %>% add_n_nodes(n = 5) # Get the graph's node IDs graph %>% get_node_ids() #> [1] 1 2 3 4 5"},{"path":"/reference/add_n_nodes_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"Add n new nodes one nodes available selection graph object class dgr_graph. New graph edges move either nodes selection toward newly created nodes (option direction = \"\"), selected nodes already graph (using direction = \"\"). Optionally, set node type edge rel values new nodes edges created, respectively. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/add_n_nodes_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"","code":"add_n_nodes_ws( graph, n, direction = NULL, type = NULL, label = NULL, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_n_nodes_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"graph graph object class dgr_graph. n number new nodes attach successor nodes nodes selection. direction Using create new edges existing nodes new nodes. option create new edges directed toward existing nodes. type optional character vector provides group identifiers nodes added. label optional character object describes nodes added. rel optional string apply rel attribute newly created edges. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_n_nodes_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_n_nodes_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a multiple of new nodes with edges to or from one or more selected nodes — add_n_nodes_ws","text":"","code":"# Create an empty graph, add a node to it, select # that node, and then add 5 more nodes to the graph # with edges from the original node to all of the # new nodes graph <- create_graph() %>% add_n_nodes(n = 1) %>% select_last_nodes_created() %>% add_n_nodes_ws( n = 5, direction = \"from\") # Get the graph's nodes graph %>% get_node_ids() #> [1] 1 2 3 4 5 6 # Get the graph's edges graph %>% get_edges() #> [1] \"1->2\" \"1->3\" \"1->4\" \"1->5\" \"1->6\" # Create an empty graph, add a node to it, select # that node, and then add 5 more nodes to the graph # with edges toward the original node from all of # the new nodes graph <- create_graph() %>% add_n_nodes(n = 1) %>% select_last_nodes_created() %>% add_n_nodes_ws( n = 5, direction = \"to\") # Get the graph's nodes graph %>% get_node_ids() #> [1] 1 2 3 4 5 6 # Get the graph's edges graph %>% get_edges() #> [1] \"2->1\" \"3->1\" \"4->1\" \"5->1\" \"6->1\""},{"path":"/reference/add_node.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a node to an existing graph object — add_node","title":"Add a node to an existing graph object — add_node","text":"graph object class dgr_graph, add new node graph. One can optionally provide node attributes created node. also option create edges existing nodes graph. new edges can also created function, possibility set edge attributes new graph edges.","code":""},{"path":"/reference/add_node.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a node to an existing graph object — add_node","text":"","code":"add_node( graph, type = NULL, label = NULL, from = NULL, to = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_node.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a node to an existing graph object — add_node","text":"graph graph object class dgr_graph. type optional character object acts group identifier node added. label optional character object describes node. optional vector containing node IDs edges directed new node. optional vector containing node IDs edges directed new node. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_node.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a node to an existing graph object — add_node","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_node.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a node to an existing graph object — add_node","text":"","code":"# Create an empty graph and add 2 nodes by using # the `add_node()` function twice graph <- create_graph() %>% add_node() %>% add_node() # Get a count of all nodes # in the graph graph %>% count_nodes() #> [1] 2 # The nodes added were given # ID values `1` and `2`; obtain # the graph's node IDs graph %>% get_node_ids() #> [1] 1 2 # Add a node with a `type` # value defined graph <- graph %>% add_node(type = \"person\") # View the graph's internal # node data frame (ndf) graph %>% get_node_df() #> id type label #> 1 1 #> 2 2 #> 3 3 person "},{"path":"/reference/add_node_clones_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Add clones of a selection of nodes — add_node_clones_ws","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"Add new nodes graph object class dgr_graph clones nodes active selection nodes. node attributes preserved except node label attribute (maintain uniqueness non-NA node label values). vector node label can provided bind new labels cloned nodes. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/add_node_clones_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"","code":"add_node_clones_ws(graph, add_edges = FALSE, direction = NULL, label = NULL)"},{"path":"/reference/add_node_clones_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"graph graph object class dgr_graph. add_edges option whether add edges selected nodes clones, , opposite direction. direction Using create new edges existing nodes new, cloned nodes. option create new edges directed toward existing nodes. label optional vector node label values. vector length correspond number nodes active selection nodes.","code":""},{"path":"/reference/add_node_clones_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_node_clones_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add clones of a selection of nodes — add_node_clones_ws","text":"","code":"# Create a graph with a path of # nodes; supply `label`, `type`, # and `value` node attributes, # and select the created nodes graph <- create_graph() %>% add_path( n = 3, label = c(\"d\", \"g\", \"r\"), type = c(\"a\", \"b\", \"c\")) %>% select_last_nodes_created() # Display the graph's internal # node data frame graph %>% get_node_df() #> id type label #> 1 1 a d #> 2 2 b g #> 3 3 c r # Create clones of all nodes # in the selection but assign # new node label values # (leaving `label` as NULL # yields NA values) graph <- graph %>% add_node_clones_ws( label = c(\"a\", \"b\", \"v\")) # Display the graph's internal # node data frame: nodes `4`, # `5`, and `6` are clones of # `1`, `2`, and `3` graph %>% get_node_df() #> id type label #> 1 1 a d #> 2 2 b g #> 3 3 c r #> 4 4 a a #> 5 5 b b #> 6 6 c v # Select the last nodes # created (`4`, `5`, and `6`) # and clone those nodes and # their attributes while # creating new edges between # the new and existing nodes graph <- graph %>% select_last_nodes_created() %>% add_node_clones_ws( add_edges = TRUE, direction = \"to\", label = c(\"t\", \"z\", \"s\")) # Display the graph's internal # edge data frame; there are # edges between the selected # nodes and their clones graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 4 7 #> 4 4 5 8 #> 5 5 6 9 "},{"path":"/reference/add_node_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Add nodes from a node data frame to an existing graph object — add_node_df","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"graph object class dgr_graph add nodes node data frame graph.","code":""},{"path":"/reference/add_node_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"","code":"add_node_df(graph, node_df)"},{"path":"/reference/add_node_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"graph graph object class dgr_graph. node_df node data frame created using create_node_df().","code":""},{"path":"/reference/add_node_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_node_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add nodes from a node data frame to an existing graph object — add_node_df","text":"","code":"# Create an empty graph graph <- create_graph() # Create a node data frame (ndf) ndf <- create_node_df(n = 2) # Add the node data frame to # the graph object to create # a graph with nodes graph <- graph %>% add_node_df( node_df = ndf) # Inspect the graph's ndf graph %>% get_node_df() #> id type label #> 1 1 #> 2 2 # Create another ndf ndf_2 <- create_node_df(n = 3) # Add the second node data # frame to the graph object # to add more nodes with # attributes to the graph graph <- graph %>% add_node_df( node_df = ndf_2) # View the graph's internal # node data frame using the # `get_node_df()` function graph %>% get_node_df() #> id type label #> 1 1 #> 2 2 #> 3 3 #> 4 4 #> 5 5 "},{"path":"/reference/add_nodes_from_df_cols.html","id":null,"dir":"Reference","previous_headings":"","what":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"Add new nodes graph object class dgr_graph using distinct values one columns data frame. values serve node labels number nodes added depends number distinct values found specified columns.","code":""},{"path":"/reference/add_nodes_from_df_cols.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"","code":"add_nodes_from_df_cols( graph, df, columns, type = NULL, keep_duplicates = FALSE )"},{"path":"/reference/add_nodes_from_df_cols.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"graph graph object class dgr_graph. df data frame values taken new nodes graph. columns character vector column names numeric vector column numbers data frame supplied df. distinct values columns serve labels nodes added graph. type optional, single-length character vector provides group identifier nodes added graph. keep_duplicates option exclude incoming nodes labels (.e., values found columns specified df) match label values available graph's nodes. default, set FALSE.","code":""},{"path":"/reference/add_nodes_from_df_cols.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_nodes_from_df_cols.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add nodes from distinct values in data frame columns — add_nodes_from_df_cols","text":"","code":"# Create an empty graph graph <- create_graph() # Create a data frame from # which several columns have # values designated as graph nodes df <- data.frame( col_1 = c(\"f\", \"p\", \"q\"), col_2 = c(\"q\", \"x\", \"f\"), col_3 = c(1, 5, 3), col_4 = c(\"a\", \"v\", \"h\"), stringsAsFactors = FALSE) # Add nodes from columns `col_1` # and `col_2` from the data frame # to the graph object graph <- graph %>% add_nodes_from_df_cols( df = df, columns = c(\"col_1\", \"col_2\")) # Show the graph's node data # frame; duplicate labels are # prevented with `keep_duplicates = # FALSE`) graph %>% get_node_df() #> id type label #> 1 1 f #> 2 2 p #> 3 3 q #> 4 4 x # Add new nodes from columns 3 and 4; # We can specify the columns by their # numbers as well graph <- graph %>% add_nodes_from_df_cols( df = df, columns = 3:4) # Show the graph's node data # frame; note that nodes didn't # get made with columns that # are not character class columns graph %>% get_node_df() #> id type label #> 1 1 f #> 2 2 p #> 3 3 q #> 4 4 x #> 5 5 a #> 6 6 v #> 7 7 h"},{"path":"/reference/add_nodes_from_table.html","id":null,"dir":"Reference","previous_headings":"","what":"Add nodes and attributes to graph from a table — add_nodes_from_table","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"Add nodes attributes existing graph object data CSV file data frame.","code":""},{"path":"/reference/add_nodes_from_table.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"","code":"add_nodes_from_table( graph, table, label_col = NULL, type_col = NULL, set_type = NULL, drop_cols = NULL )"},{"path":"/reference/add_nodes_from_table.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"graph graph object class dgr_graph. table Either path CSV file, , data frame object. label_col option apply column data table label attribute values. type_col option apply column data table type attribute values. set_type optional string apply type attribute nodes created data external table. drop_cols optional column selection statement dropping columns external table inclusion attributes graph's internal node data frame. Several columns can dropped name using syntax col_1 & col_2 & .... Columns can also dropped using numeric column range : (e.g., 5:8), , using : column names specify range (e.g., col_5_name:col_8_name).","code":""},{"path":"/reference/add_nodes_from_table.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_nodes_from_table.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add nodes and attributes to graph from a table — add_nodes_from_table","text":"","code":"# To add nodes from the dataset called # `currencies` (available as a dataset # in the package), call the # `add_nodes_from_table()` function # after creating an empty graph; new # node ID values will be created as # monotonically-increasing values graph_1 <- create_graph() %>% add_nodes_from_table( table = currencies) # View part of the graph's internal # node data frame (ndf) graph_1 %>% get_node_df() %>% .[, 1:5] %>% head() #> id type label iso_4217_code curr_number #> 1 1 AED 784 #> 2 2 AFN 971 #> 3 3 ALL 8 #> 4 4 AMD 51 #> 5 5 ANG 532 #> 6 6 AOA 973 # If you would like to assign # any of the table's columns as # `type` or `label` attributes, # this can be done with the `type_col` # and `label_col` arguments; to set # a static `type` attribute for all # of the table records, use `set_type` graph_2 <- create_graph() %>% add_nodes_from_table( table = currencies, label_col = iso_4217_code, set_type = currency) # View part of the graph's internal ndf graph_2 %>% get_node_df() %>% .[, 1:5] %>% head() #> id type label curr_number exponent #> 1 1 currency AED 784 2 #> 2 2 currency AFN 971 2 #> 3 3 currency ALL 8 2 #> 4 4 currency AMD 51 2 #> 5 5 currency ANG 532 2 #> 6 6 currency AOA 973 2 # Suppose we would like to not # include certain columns from the # external table in the resulting # graph; we can use the `drop_cols` # argument to choose which columns # to not include as attributes graph_3 <- create_graph() %>% add_nodes_from_table( table = currencies, label_col = iso_4217_code, set_type = currency, drop_cols = exponent & currency_name) # Show the node attribute names # for the graph; note that the # `exponent` and `currency_name` # columns are not attributes in the # graph's internal node data frame graph_3 %>% get_node_df() %>% colnames() #> [1] \"id\" \"type\" \"label\" \"curr_number\""},{"path":"/reference/add_pa_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a preferential attachment graph — add_pa_graph","title":"Add a preferential attachment graph — add_pa_graph","text":"existing graph object, add graph built according Barabasi-Albert model, uses preferential attachment stochastic algorithm.","code":""},{"path":"/reference/add_pa_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a preferential attachment graph — add_pa_graph","text":"","code":"add_pa_graph( graph, n, m = NULL, power = 1, out_dist = NULL, use_total_degree = FALSE, zero_appeal = 1, algo = \"psumtree\", type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_pa_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a preferential attachment graph — add_pa_graph","text":"graph graph object class dgr_graph. n number nodes comprising preferential attachment graph. m number edges add time step. power power preferential attachment. default value 1 indicates linear preferential attachment. out_dist numeric vector provides distribution number edges add time step. use_total_degree logical value (default TRUE) governs whether total degree used calculating citation probability. FALSE, indegree used. zero_appeal measure attractiveness nodes adjacent edges. algo algorithm use generate graph. available options psumtree, psumtree-multiple, bag. psumtree algorithm, partial prefix-sum tree used create graph. values power zero_appeal can provided algorithm never generates multiple edges. psumtree-multiple algorithm also uses partial prefix-sum tree difference multiple edges allowed. bag algorithm places node IDs bag many times -degree (plus ). required number cited nodes drawn bag replacement. Multiple edges may produced using method (disallowed). type optional string describes entity type nodes added. label logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_pa_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a preferential attachment graph — add_pa_graph","text":"","code":"# Create an undirected PA # graph with 100 nodes, adding # 2 edges at every time step pa_graph <- create_graph( directed = FALSE) %>% add_pa_graph( n = 100, m = 1) # Get a count of nodes pa_graph %>% count_nodes() #> [1] 100 # Get a count of edges pa_graph %>% count_edges() #> [1] 99"},{"path":"/reference/add_path.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a path of nodes to the graph — add_path","title":"Add a path of nodes to the graph — add_path","text":"graph object class dgr_graph, add node path graph.","code":""},{"path":"/reference/add_path.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a path of nodes to the graph — add_path","text":"","code":"add_path( graph, n, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_path.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a path of nodes to the graph — add_path","text":"graph graph object class dgr_graph. n number nodes comprising path. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node path. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_path.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a path of nodes to the graph — add_path","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_path.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a path of nodes to the graph — add_path","text":"","code":"# Create a new graph and add # 2 paths of varying lengths graph <- create_graph() %>% add_path( n = 4, type = \"path\") %>% add_path( n = 5, type = \"path\") # Get node information # from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 path 1 1 0 1 0 #> 2 2 path 2 2 1 1 0 #> 3 3 path 3 2 1 1 0 #> 4 4 path 4 1 1 0 0 #> 5 5 path 5 1 0 1 0 #> 6 6 path 6 2 1 1 0 #> 7 7 path 7 2 1 1 0 #> 8 8 path 8 2 1 1 0 #> 9 9 path 9 1 1 0 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) graph_w_attrs <- create_graph() %>% add_path( n = 3, label = c( \"one\", \"two\", \"three\"), type = c( \"a\", \"a\", \"b\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), edge_aes = edge_aes( color = \"red\", penwidth = 1.2), node_data = node_data( value = c( 1.6, 2.8, 3.4)), edge_data = edge_data( value = rnorm( n = 2, mean = 5.0, sd = 1.0))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 a two steelblue 2.8 #> 3 3 b three steelblue 3.4 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 A 1.2 red 5.996605 #> 2 2 2 3 A 1.2 red 6.107490"},{"path":"/reference/add_prism.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a prism of nodes to the graph — add_prism","title":"Add a prism of nodes to the graph — add_prism","text":"graph object class dgr_graph, add node prism graph.","code":""},{"path":"/reference/add_prism.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a prism of nodes to the graph — add_prism","text":"","code":"add_prism( graph, n, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_prism.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a prism of nodes to the graph — add_prism","text":"graph graph object class dgr_graph. n number nodes describing shape prism. example, triangular prism n equal 3 composed 6 nodes 9 edges. n-gonal prism, graph generated 2n nodes 3n edges. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node prism. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_prism.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a prism of nodes to the graph — add_prism","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_prism.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a prism of nodes to the graph — add_prism","text":"","code":"# Create a new graph and # add 2 prisms graph <- create_graph() %>% add_prism( n = 3, type = \"prism\", label = \"a\") %>% add_prism( n = 3, type = \"prism\", label = \"b\") # Get node information from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 prism a 3 1 2 0 #> 2 2 prism a 3 1 2 0 #> 3 3 prism a 3 1 2 0 #> 4 4 prism a 3 2 1 0 #> 5 5 prism a 3 2 1 0 #> 6 6 prism a 3 2 1 0 #> 7 7 prism b 3 1 2 0 #> 8 8 prism b 3 1 2 0 #> 9 9 prism b 3 1 2 0 #> 10 10 prism b 3 2 1 0 #> 11 11 prism b 3 2 1 0 #> 12 12 prism b 3 2 1 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) graph_w_attrs <- create_graph() %>% add_prism( n = 3, label = c( \"one\", \"two\", \"three\", \"four\", \"five\", \"six\"), type = c( \"a\", \"a\", \"b\", \"b\", \"c\", \"c\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), edge_aes = edge_aes( color = \"red\", penwidth = 1.2), node_data = node_data( value = c( 1.6, 2.8, 3.4, 3.2, 5.3, 6.2)), edge_data = edge_data( value = rnorm( n = 9, mean = 5.0, sd = 1.0))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 a two steelblue 2.8 #> 3 3 b three steelblue 3.4 #> 4 4 b four steelblue 3.2 #> 5 5 c five steelblue 5.3 #> 6 6 c six steelblue 6.2 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 A 1.2 red 5.996605 #> 2 2 2 3 A 1.2 red 6.107490 #> 3 3 3 1 A 1.2 red 4.721914 #> 4 4 4 5 A 1.2 red 6.019205 #> 5 5 5 6 A 1.2 red 5.045437 #> 6 6 6 4 A 1.2 red 6.575780 #> 7 7 1 4 A 1.2 red 5.218288 #> 8 8 2 5 A 1.2 red 3.953465 #> 9 9 3 6 A 1.2 red 4.711311"},{"path":"/reference/add_reverse_edges_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"Add edges opposite direction one edges available edge selection graph object class dgr_graph. New graph edges opposite edge definitions selection. example, graph edge 1->2 active selection gain new 2->1 edge. also option assign common rel grouping newly created edges. Upon addition edges, edge selection retained selection traversal operations. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/add_reverse_edges_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"","code":"add_reverse_edges_ws(graph, rel = NULL, edge_aes = NULL, edge_data = NULL)"},{"path":"/reference/add_reverse_edges_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"graph graph object class dgr_graph. rel optional string apply rel attribute newly created edges. edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_reverse_edges_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/add_reverse_edges_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add new edges in the opposite directions of a selection of edges — add_reverse_edges_ws","text":"","code":"# Create an empty graph, add 2 nodes to it, # and create the edge `1->2` graph <- create_graph() %>% add_n_nodes( n = 2, type = \"type_a\", label = c(\"a_1\", \"a_2\")) %>% add_edge( from = 1, to = 2, rel = \"a\") # Get the graph's edges graph %>% get_edge_ids() #> [1] 1 # Select the edge and create 2 additional edges # with the opposite definition of `1->2`, which # is `2->1`; also, apply, different `rel` values # (`b` and `c`) graph <- graph %>% select_edges() %>% add_reverse_edges_ws(rel = \"b\") %>% add_reverse_edges_ws(rel = \"c\") %>% clear_selection() # Get the graph's edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 a #> 2 2 2 1 b #> 3 3 2 1 c"},{"path":"/reference/add_smallworld_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"existing graph object, add graph built according Watts-Strogatz small-world model, uses lattice along rewiring probability randomly modify edge definitions.","code":""},{"path":"/reference/add_smallworld_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"","code":"add_smallworld_graph( graph, dimension, size, neighborhood, p, loops = FALSE, multiple = FALSE, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL )"},{"path":"/reference/add_smallworld_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"graph graph object class dgr_graph. dimension dimension starting lattice. size size lattice across dimension. neighborhood neighborhood lattice nodes connected. p rewiring probability. loops logical value (default FALSE) governs whether loops allowed created. multiple logical value (default FALSE) governs whether multiple edges allowed created. type optional string describes entity type nodes added. label logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label edges added. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges. set_seed Supplying value sets random seed Mersenne-Twister implementation.","code":""},{"path":"/reference/add_smallworld_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_smallworld_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a Watts-Strogatz small-world graph — add_smallworld_graph","text":"","code":"# Create an undirected smallworld # graph with 100 nodes using # a probability value of 0.05 smallworld_graph <- create_graph( directed = FALSE) %>% add_smallworld_graph( dimension = 1, size = 50, neighborhood = 1, p = 0.05, set_seed = 23) # Get a count of nodes smallworld_graph %>% count_nodes() #> [1] 50 # Get a count of edges smallworld_graph %>% count_edges() #> [1] 50"},{"path":"/reference/add_star.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a star of nodes to the graph — add_star","title":"Add a star of nodes to the graph — add_star","text":"graph object class dgr_graph, add node star graph.","code":""},{"path":"/reference/add_star.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a star of nodes to the graph — add_star","text":"","code":"add_star( graph, n, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )"},{"path":"/reference/add_star.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a star of nodes to the graph — add_star","text":"graph graph object class dgr_graph. n number nodes comprising star. first node center star. type optional string describes entity type nodes added. label Either vector object length n provides optional labels new nodes, , logical value setting TRUE ascribes node IDs label FALSE yields blank label. rel optional string providing relationship label new edges created node star. node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":"/reference/add_star.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add a star of nodes to the graph — add_star","text":"graph object class dgr_graph.","code":""},{"path":"/reference/add_star.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a star of nodes to the graph — add_star","text":"","code":"# Create a new graph and add 2 # stars of varying numbers of nodes graph <- create_graph() %>% add_star( n = 4, type = \"four_star\") %>% add_star( n = 5, type = \"five_star\") # Get node information from this graph graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 four_star 1 3 0 3 0 #> 2 2 four_star 2 1 1 0 0 #> 3 3 four_star 3 1 1 0 0 #> 4 4 four_star 4 1 1 0 0 #> 5 5 five_star 5 4 0 4 0 #> 6 6 five_star 6 1 1 0 0 #> 7 7 five_star 7 1 1 0 0 #> 8 8 five_star 8 1 1 0 0 #> 9 9 five_star 9 1 1 0 0 # Node and edge aesthetic and data # attributes can be specified in # the `node_aes`, `edge_aes`, # `node_data`, and `edge_data` # arguments suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) graph_w_attrs <- create_graph() %>% add_star( n = 4, label = c( \"one\", \"two\", \"three\", \"four\"), type = c( \"a\", \"a\", \"b\", \"b\"), rel = \"A\", node_aes = node_aes( fillcolor = \"steelblue\"), edge_aes = edge_aes( color = \"red\", penwidth = 1.2), node_data = node_data( value = c( 1.6, 2.8, 3.4, 8.3)), edge_data = edge_data( value = rnorm( n = 3, mean = 5.0, sd = 1.0))) # Get the graph's node data frame graph_w_attrs %>% get_node_df() #> id type label fillcolor value #> 1 1 a one steelblue 1.6 #> 2 2 a two steelblue 2.8 #> 3 3 b three steelblue 3.4 #> 4 4 b four steelblue 8.3 # Get the graph's edge data frame graph_w_attrs %>% get_edge_df() #> id from to rel penwidth color value #> 1 1 1 2 A 1.2 red 5.996605 #> 2 2 1 3 A 1.2 red 6.107490 #> 3 3 1 4 A 1.2 red 4.721914"},{"path":"/reference/clear_selection.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear an active selection of nodes or edges — clear_selection","title":"Clear an active selection of nodes or edges — clear_selection","text":"Clear selection nodes edges within graph object.","code":""},{"path":"/reference/clear_selection.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear an active selection of nodes or edges — clear_selection","text":"","code":"clear_selection(graph)"},{"path":"/reference/clear_selection.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Clear an active selection of nodes or edges — clear_selection","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/clear_selection.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear an active selection of nodes or edges — clear_selection","text":"graph object class dgr_graph.","code":""},{"path":"/reference/clear_selection.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Clear an active selection of nodes or edges — clear_selection","text":"","code":"# Create a graph with # a single path graph <- create_graph() %>% add_path(n = 5) # Select nodes with IDs `1` # and `3` graph <- graph %>% select_nodes( nodes = c(1, 3)) # Verify that a node selection # has been made graph %>% get_selection() #> [1] 1 3 # Clear the selection with # `clear_selection()` graph <- graph %>% clear_selection() # Verify that the node # selection has been cleared graph %>% get_selection() #> [1] NA"},{"path":"/reference/colorize_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply colors based on edge attribute values — colorize_edge_attrs","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"Within graph's internal edge data frame (edf), use categorical edge attribute generate new edge attribute color values.","code":""},{"path":"/reference/colorize_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"","code":"colorize_edge_attrs( graph, edge_attr_from, edge_attr_to, cut_points = NULL, palette = \"Spectral\", alpha = NULL, reverse_palette = FALSE, default_color = \"#D9D9D9\" )"},{"path":"/reference/colorize_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from name edge attribute column color values based. edge_attr_to name new edge attribute color values applied. cut_points optional vector numerical breaks bucketizing continuous numerical values available edge attribute column. palette Can either : (1) palette name RColorBrewer package (e.g., Greens, OrRd, RdYlGn), (2) viridis, indicates use viridis color scale package name, (3) vector hexadecimal color names. alpha optional alpha transparency value apply generated colors. range 0 (completely transparent) 100 (completely opaque). reverse_palette option reverse order colors chosen palette. default FALSE. default_color hexadecimal color value use instances values fall bucket ranges specified cut_points vector.","code":""},{"path":"/reference/colorize_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":"/reference/colorize_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply colors based on edge attribute values — colorize_edge_attrs","text":"","code":"# Create a graph with 5 # nodes and 4 edges graph <- create_graph() %>% add_path(n = 5) %>% set_edge_attrs( edge_attr = weight, values = c(3.7, 6.3, 9.2, 1.6)) # We can bucketize values in # the edge `weight` attribute using # `cut_points` and, by doing so, # assign colors to each of the # bucketed ranges (for values not # part of any bucket, a gray color # is assigned by default) graph <- graph %>% colorize_edge_attrs( edge_attr_from = weight, edge_attr_to = color, cut_points = c(0, 2, 4, 6, 8, 10), palette = \"RdYlGn\") # Now there will be a `color` # edge attribute with distinct # colors (from the RColorBrewer # Red-Yellow-Green palette) graph %>% get_edge_df() #> id from to rel weight color #> 1 1 1 2 3.7 #FDAE61 #> 2 2 2 3 6.3 #A6D96A #> 3 3 3 4 9.2 #1A9641 #> 4 4 4 5 1.6 #D7191C"},{"path":"/reference/colorize_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply colors based on node attribute values — colorize_node_attrs","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"Within graph's internal node data frame (ndf), use categorical node attribute generate new node attribute color values.","code":""},{"path":"/reference/colorize_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"","code":"colorize_node_attrs( graph, node_attr_from, node_attr_to, cut_points = NULL, palette = \"Spectral\", alpha = NULL, reverse_palette = FALSE, default_color = \"#D9D9D9\" )"},{"path":"/reference/colorize_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"graph graph object class dgr_graph. node_attr_from name node attribute column color values based. node_attr_to name new node attribute color values applied. cut_points optional vector numerical breaks bucketizing continuous numerical values available edge attribute column. palette Can either : (1) palette name RColorBrewer package (e.g., Greens, OrRd, RdYlGn), (2) viridis, indicates use viridis color scale package name, (3) vector hexadecimal color names. alpha optional alpha transparency value apply generated colors. range 0 (completely transparent) 100 (completely opaque). reverse_palette option reverse order colors chosen palette. default FALSE. default_color hexadecimal color value use instances values fall bucket ranges specified cut_points vector.","code":""},{"path":"/reference/colorize_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/colorize_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply colors based on node attribute values — colorize_node_attrs","text":"","code":"# Create a graph with 8 # nodes and 7 edges graph <- create_graph() %>% add_path(n = 8) %>% set_node_attrs( node_attr = weight, values = c( 8.2, 3.7, 6.3, 9.2, 1.6, 2.5, 7.2, 5.4)) # Find group membership values for all nodes # in the graph through the Walktrap community # finding algorithm and join those group values # to the graph's internal node data frame (ndf) # with the `join_node_attrs()` function graph <- graph %>% join_node_attrs( df = get_cmty_walktrap(.)) # Inspect the number of distinct communities graph %>% get_node_attrs( node_attr = walktrap_group) %>% unique() %>% sort() #> [1] 1 2 3 # Visually distinguish the nodes in the different # communities by applying colors using the # `colorize_node_attrs()` function; specifically, # set different `fillcolor` values with an alpha # value of 90 and apply opaque colors to the node # border (with the `color` node attribute) graph <- graph %>% colorize_node_attrs( node_attr_from = walktrap_group, node_attr_to = fillcolor, palette = \"Greens\", alpha = 90) %>% colorize_node_attrs( node_attr_from = walktrap_group, node_attr_to = color, palette = \"viridis\", alpha = 80) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label weight walktrap_group fillcolor color #> 1 1 1 8.2 2 #A1D99B90 #21908C80 #> 2 2 2 3.7 2 #A1D99B90 #21908C80 #> 3 3 3 6.3 2 #A1D99B90 #21908C80 #> 4 4 4 9.2 3 #31A35490 #FDE72580 #> 5 5 5 1.6 3 #31A35490 #FDE72580 #> 6 6 6 2.5 1 #E5F5E090 #44015480 #> 7 7 7 7.2 1 #E5F5E090 #44015480 #> 8 8 8 5.4 1 #E5F5E090 #44015480 # Create a graph with 8 nodes and 7 edges graph <- create_graph() %>% add_path(n = 8) %>% set_node_attrs( node_attr = weight, values = c( 8.2, 3.7, 6.3, 9.2, 1.6, 2.5, 7.2, 5.4)) # We can bucketize values in `weight` using # `cut_points` and assign colors to each of the # bucketed ranges (for values not part of any # bucket, a gray color is assigned by default) graph <- graph %>% colorize_node_attrs( node_attr_from = weight, node_attr_to = fillcolor, cut_points = c(1, 3, 5, 7, 9)) # Now there will be a `fillcolor` node attribute # with distinct colors (the `#D9D9D9` color is # the default `gray85` color) graph %>% get_node_df() #> id type label weight fillcolor #> 1 1 1 8.2 #2B83BA #> 2 2 2 3.7 #FDAE61 #> 3 3 3 6.3 #ABDDA4 #> 4 4 4 9.2 #D9D9D9 #> 5 5 5 1.6 #D7191C #> 6 6 6 2.5 #D7191C #> 7 7 7 7.2 #2B83BA #> 8 8 8 5.4 #ABDDA4"},{"path":"/reference/combine_edfs.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine multiple edge data frames into a single edge data frame — combine_edfs","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"Combine several edge data frames style rbind(), except, works regardless number ordering columns.","code":""},{"path":"/reference/combine_edfs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"","code":"combine_edfs(...)"},{"path":"/reference/combine_edfs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"... Two edge data frames, contain edge IDs associated attributes.","code":""},{"path":"/reference/combine_edfs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"combined edge data frame.","code":""},{"path":"/reference/combine_edfs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine multiple edge data frames into a single edge data frame — combine_edfs","text":"","code":"# Create an edge data frame (edf) edf_1 <- create_edge_df( from = c(1, 1, 2, 3), to = c(2, 4, 4, 1), rel = \"requires\", color = \"green\", data = c(2.7, 8.9, 2.6, 0.6)) # Create a second edge data frame edf_2 <- create_edge_df( from = c(5, 7, 8, 8), to = c(7, 8, 6, 5), rel = \"receives\", arrowhead = \"dot\", color = \"red\") # Combine the two edge data frames all_edges <- combine_edfs(edf_1, edf_2) # View the combined edge data frame all_edges #> id from to rel color data arrowhead #> 1 1 1 2 requires green 2.7 #> 2 2 1 4 requires green 8.9 #> 3 3 2 4 requires green 2.6 #> 4 4 3 1 requires green 0.6 #> 5 5 5 7 receives red NA dot #> 6 6 7 8 receives red NA dot #> 7 7 8 6 receives red NA dot #> 8 8 8 5 receives red NA dot"},{"path":"/reference/combine_graphs.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine two graphs into a single graph — combine_graphs","title":"Combine two graphs into a single graph — combine_graphs","text":"Combine two graphs order make new graph.","code":""},{"path":"/reference/combine_graphs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine two graphs into a single graph — combine_graphs","text":"","code":"combine_graphs(x, y)"},{"path":"/reference/combine_graphs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine two graphs into a single graph — combine_graphs","text":"x DiagrammeR graph object another graph unioned. graph considered graph global graph attributes inherited resulting graph. y DiagrammeR graph object unioned graph supplied x.","code":""},{"path":"/reference/combine_graphs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine two graphs into a single graph — combine_graphs","text":"graph object class dgr_graph.","code":""},{"path":"/reference/combine_graphs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine two graphs into a single graph — combine_graphs","text":"","code":"# Create a graph with a cycle # containing 6 nodes graph_cycle <- create_graph() %>% add_cycle(n = 6) # Create a random graph with # 8 nodes and 15 edges using the # `add_gnm_graph()` function graph_random <- create_graph() %>% add_gnm_graph( n = 8, m = 15, set_seed = 23) # Combine the two graphs in a # union operation combined_graph <- combine_graphs( graph_cycle, graph_random) # Get the number of nodes in # the combined graph combined_graph %>% count_nodes() #> [1] 14 # The `combine_graphs()` # function will renumber # node ID values in graph `y` # during the union; this ensures # that node ID values are unique combined_graph %>% get_node_ids() #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14"},{"path":"/reference/combine_ndfs.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine multiple node data frames — combine_ndfs","title":"Combine multiple node data frames — combine_ndfs","text":"Combine several node data frames single node data frame.","code":""},{"path":"/reference/combine_ndfs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine multiple node data frames — combine_ndfs","text":"","code":"combine_ndfs(...)"},{"path":"/reference/combine_ndfs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine multiple node data frames — combine_ndfs","text":"... Two node data frames, contain node IDs associated attributes.","code":""},{"path":"/reference/combine_ndfs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine multiple node data frames — combine_ndfs","text":"combined node data frame.","code":""},{"path":"/reference/combine_ndfs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine multiple node data frames — combine_ndfs","text":"","code":"# Create two node data frames node_df_1 <- create_node_df( n = 2, type = c(\"a\", \"b\"), label = c(\"D\", \"Z\"), value = c(8.4, 3.4)) node_df_2 <- create_node_df( n = 2, type = c(\"b\", \"c\"), label = c(\"U\", \"A\"), value = c(0.4, 3.4)) # Combine the ndfs using the # `combine_ndfs()` function node_df_combined <- combine_ndfs( node_df_1, node_df_2) # Inspect the combined ndf node_df_combined #> id type label value #> 1 1 a D 8.4 #> 2 2 b Z 3.4 #> 3 3 b U 0.4 #> 4 4 c A 3.4"},{"path":"/reference/copy_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Copy an edge attribute column and set the name — copy_edge_attrs","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"Within graph's internal edge data frame (edf), copy contents existing edge attribute create distinct edge attribute within edf different attribute name.","code":""},{"path":"/reference/copy_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"","code":"copy_edge_attrs(graph, edge_attr_from, edge_attr_to)"},{"path":"/reference/copy_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from name edge attribute column values copied. edge_attr_to name new edge attribute column copied values placed.","code":""},{"path":"/reference/copy_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/copy_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Copy an edge attribute column and set the name — copy_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 8, set_seed = 23) %>% set_edge_attrs( edge_attr = color, values = \"green\") # Get the graph's internal # edf to show which edge # attributes are available graph %>% get_edge_df() #> id from to rel color #> 1 1 1 3 green #> 2 2 2 1 green #> 3 3 2 5 green #> 4 4 2 3 green #> 5 5 3 2 green #> 6 6 3 5 green #> 7 7 3 4 green #> 8 8 5 3 green # Make a copy the `color` # edge attribute as the # `color_2` edge attribute graph <- graph %>% copy_edge_attrs( edge_attr_from = color, edge_attr_to = color_2) # Get the graph's internal # edf to show that the edge # attribute had been copied graph %>% get_edge_df() #> id from to rel color color_2 #> 1 1 1 3 green green #> 2 2 2 1 green green #> 3 3 2 5 green green #> 4 4 2 3 green green #> 5 5 3 2 green green #> 6 6 3 5 green green #> 7 7 3 4 green green #> 8 8 5 3 green green"},{"path":"/reference/copy_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Copy a node attribute column and set the name — copy_node_attrs","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"Within graph's internal node data frame (ndf), copy contents existing node attribute create distinct node attribute within ndf different attribute name.","code":""},{"path":"/reference/copy_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"","code":"copy_node_attrs(graph, node_attr_from, node_attr_to)"},{"path":"/reference/copy_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"graph graph object class dgr_graph. node_attr_from name node attribute column values copied. node_attr_to name new node attribute column copied values placed.","code":""},{"path":"/reference/copy_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/copy_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Copy a node attribute column and set the name — copy_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) %>% set_node_attrs( node_attr = shape, values = \"circle\") %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the graph's internal # ndf to show which node # attributes are available graph %>% get_node_df() #> id type label shape value #> 1 1 1 circle 5.3 #> 2 2 2 circle 4.4 #> 3 3 3 circle 5.8 #> 4 4 4 circle 5.9 #> 5 5 5 circle 6.2 # Make a copy the `value` # node attribute as the # `width` node attribute graph <- graph %>% copy_node_attrs( node_attr_from = value, node_attr_to = size) # Get the graph's internal # ndf to show that the node # attribute had been copied graph %>% get_node_df() #> id type label shape value size #> 1 1 1 circle 5.3 5.3 #> 2 2 2 circle 4.4 4.4 #> 3 3 3 circle 5.8 5.8 #> 4 4 4 circle 5.9 5.9 #> 5 5 5 circle 6.2 6.2"},{"path":"/reference/count_asymmetric_node_pairs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"Get number asymmetrically-connected node pairs. works directed graphs.","code":""},{"path":"/reference/count_asymmetric_node_pairs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"","code":"count_asymmetric_node_pairs(graph)"},{"path":"/reference/count_asymmetric_node_pairs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_asymmetric_node_pairs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"single numeric value representing number asymmetrically-connected node pairs.","code":""},{"path":"/reference/count_asymmetric_node_pairs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of asymmetrically-connected node pairs — count_asymmetric_node_pairs","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Get a count of asymmetrically- # connected node pairs graph %>% count_asymmetric_node_pairs() #> [1] 5 # Create a full graph and then # count the asymmetrically- # connected node pairs create_graph() %>% add_full_graph(n = 10) %>% count_asymmetric_node_pairs() #> [1] 0"},{"path":"/reference/count_automorphisms.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of automorphisms — count_automorphisms","title":"Get the number of automorphisms — count_automorphisms","text":"Get number automorphisms graph contains. automorphism graph form symmetry graph mapped onto preserving edge-node connectivity.","code":""},{"path":"/reference/count_automorphisms.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of automorphisms — count_automorphisms","text":"","code":"count_automorphisms(graph)"},{"path":"/reference/count_automorphisms.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of automorphisms — count_automorphisms","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_automorphisms.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of automorphisms — count_automorphisms","text":"single numeric value representing number automorphisms graph contains.","code":""},{"path":"/reference/count_automorphisms.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of automorphisms — count_automorphisms","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Get a count of automorphisms graph %>% count_automorphisms() #> [1] 10 # Create a full graph and then # count the automorphisms create_graph() %>% add_full_graph(n = 10) %>% count_automorphisms() #> [1] 3628800"},{"path":"/reference/count_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a count of all edges — count_edges","title":"Get a count of all edges — count_edges","text":"graph object class dgr_graph, get count edges graph.","code":""},{"path":"/reference/count_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a count of all edges — count_edges","text":"","code":"count_edges(graph)"},{"path":"/reference/count_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a count of all edges — count_edges","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a count of all edges — count_edges","text":"single-length numeric vector.","code":""},{"path":"/reference/count_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a count of all edges — count_edges","text":"","code":"# Create a graph with a # path of nodes and 3 # unconnected nodes graph <- create_graph() %>% add_path(n = 3) %>% add_n_nodes(n = 3) # Get a count of all edges # in the graph graph %>% count_edges() #> [1] 2"},{"path":"/reference/count_graphs_in_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Count graphs in a graph series object — count_graphs_in_graph_series","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"Counts total number graphs graph series object.","code":""},{"path":"/reference/count_graphs_in_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"","code":"count_graphs_in_graph_series(graph_series)"},{"path":"/reference/count_graphs_in_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"graph_series graph series object type dgr_graph_1D","code":""},{"path":"/reference/count_graphs_in_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"numeric vector representing count graphs graph series object.","code":""},{"path":"/reference/count_graphs_in_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Count graphs in a graph series object — count_graphs_in_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Count the number of graphs # in the graph series series %>% count_graphs_in_graph_series() #> [1] 3"},{"path":"/reference/count_loop_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Get count of all loop edges — count_loop_edges","title":"Get count of all loop edges — count_loop_edges","text":"graph object class dgr_graph, get count loop edges graph.","code":""},{"path":"/reference/count_loop_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get count of all loop edges — count_loop_edges","text":"","code":"count_loop_edges(graph)"},{"path":"/reference/count_loop_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get count of all loop edges — count_loop_edges","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_loop_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get count of all loop edges — count_loop_edges","text":"numeric vector single length.","code":""},{"path":"/reference/count_loop_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get count of all loop edges — count_loop_edges","text":"","code":"# Create an undirected, full graph # with 3 nodes and all possible # edges, including loop edges graph <- create_graph( directed = FALSE) %>% add_full_graph( n = 3, keep_loops = TRUE) # Get a count of all loop edges # in the graph graph %>% count_loop_edges() #> [1] 3"},{"path":"/reference/count_mutual_node_pairs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"Get number mutually-connected node pairs. works directed graphs.","code":""},{"path":"/reference/count_mutual_node_pairs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"","code":"count_mutual_node_pairs(graph)"},{"path":"/reference/count_mutual_node_pairs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_mutual_node_pairs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"single numeric value representing number mutually-connected node pairs.","code":""},{"path":"/reference/count_mutual_node_pairs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of mutually-connected node pairs — count_mutual_node_pairs","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Get a count of mutually-connected # node pairs graph %>% count_mutual_node_pairs() #> [1] 0 # Create a full graph and then # count the mutually-connected # node pairs create_graph() %>% add_full_graph(n = 10) %>% count_mutual_node_pairs() #> [1] 45"},{"path":"/reference/count_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a count of all nodes — count_nodes","title":"Get a count of all nodes — count_nodes","text":"graph object class dgr_graph, get count nodes graph.","code":""},{"path":"/reference/count_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a count of all nodes — count_nodes","text":"","code":"count_nodes(graph)"},{"path":"/reference/count_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a count of all nodes — count_nodes","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a count of all nodes — count_nodes","text":"numeric vector single length.","code":""},{"path":"/reference/count_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a count of all nodes — count_nodes","text":"","code":"# Create a graph with a # path of nodes and 3 # unconnected nodes graph <- create_graph() %>% add_path(n = 3) %>% add_n_nodes(n = 3) # Get a count of all nodes # in the graph graph %>% count_nodes() #> [1] 6"},{"path":"/reference/count_s_connected_cmpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of strongly-connected components — count_s_connected_cmpts","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"Get number strongly-connected components graph.","code":""},{"path":"/reference/count_s_connected_cmpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"","code":"count_s_connected_cmpts(graph)"},{"path":"/reference/count_s_connected_cmpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_s_connected_cmpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"single integer value representing number strongly-connected graph components.","code":""},{"path":"/reference/count_s_connected_cmpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of strongly-connected components — count_s_connected_cmpts","text":"","code":"# Create a graph and add # several graph islands graph <- create_graph() %>% add_islands_graph( n_islands = 4, island_size = 10, p = 1/5, edges_between = 1, set_seed = 23) # Get a count of strongly-connected # components in the graph graph %>% count_s_connected_cmpts() #> [1] 4"},{"path":"/reference/count_unconnected_node_pairs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of unconnected node pairs — count_unconnected_node_pairs","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"Get number unconnected node pairs. works directed graphs.","code":""},{"path":"/reference/count_unconnected_node_pairs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"","code":"count_unconnected_node_pairs(graph)"},{"path":"/reference/count_unconnected_node_pairs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_unconnected_node_pairs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"single numeric value representing number unconnected node pairs.","code":""},{"path":"/reference/count_unconnected_node_pairs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of unconnected node pairs — count_unconnected_node_pairs","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Get a count of unconnected node # pairs in the graph graph %>% count_unconnected_node_pairs() #> [1] 5 # Create a full graph and then # count all unconnected node pairs create_graph() %>% add_full_graph(n = 10) %>% count_unconnected_node_pairs() #> [1] 0"},{"path":"/reference/count_unconnected_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Get count of all unconnected nodes — count_unconnected_nodes","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"graph object class dgr_graph, get count nodes graph connected node.","code":""},{"path":"/reference/count_unconnected_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"","code":"count_unconnected_nodes(graph)"},{"path":"/reference/count_unconnected_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_unconnected_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"numeric vector single length.","code":""},{"path":"/reference/count_unconnected_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get count of all unconnected nodes — count_unconnected_nodes","text":"","code":"# Create a graph with a # path of nodes and 3 # unconnected nodes graph <- create_graph() %>% add_path(n = 3) %>% add_n_nodes(n = 3) # Get a count of all nodes # in the graph graph %>% count_nodes() #> [1] 6 # Get a count of all # unconnected nodes in the # graph graph %>% count_unconnected_nodes() #> [1] 3"},{"path":"/reference/count_w_connected_cmpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the number of weakly-connected components — count_w_connected_cmpts","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"Get number weakly-connected components graph.","code":""},{"path":"/reference/count_w_connected_cmpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"","code":"count_w_connected_cmpts(graph)"},{"path":"/reference/count_w_connected_cmpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/count_w_connected_cmpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"single integer value representing number weakly-connected graph components.","code":""},{"path":"/reference/count_w_connected_cmpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the number of weakly-connected components — count_w_connected_cmpts","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) %>% add_cycle(n = 5) # Get a count of weakly-connected # components in the graph graph %>% count_w_connected_cmpts() #> [1] 2"},{"path":"/reference/create_edge_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an edge data frame — create_edge_df","title":"Create an edge data frame — create_edge_df","text":"Combine several vectors edges attributes data frame, can combined similarly-generated data frames, , added graph object. edge data frame, edf, least following columns: id (type integer) (type integer) (type integer) rel (type character) arbitrary number additional columns containing aesthetic data attributes can part edf, long follow aforementioned columns.","code":""},{"path":"/reference/create_edge_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an edge data frame — create_edge_df","text":"","code":"create_edge_df(from, to, rel = NULL, ...)"},{"path":"/reference/create_edge_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an edge data frame — create_edge_df","text":"vector node ID values edges outbound. vector length must equal vector. vector node ID values edges incoming. vector length must equal vector. rel optional rel label edge. ... One vectors associated edge attributes.","code":""},{"path":"/reference/create_edge_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an edge data frame — create_edge_df","text":"edge data frame (edf).","code":""},{"path":[]},{"path":"/reference/create_edge_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create an edge data frame — create_edge_df","text":"","code":"# Create a simple edge data frame (edf) and # view the results edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"a\") # Display the edge data frame edf #> id from to rel #> 1 1 1 4 a #> 2 2 2 3 a #> 3 3 3 1 a # Create an edf with additional edge # attributes (where their classes will # be inferred from the input vectors) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"a\", length = c(50, 100, 250), color = \"green\", width = c(1, 5, 2)) # Display the edge data frame edf #> id from to rel length color width #> 1 1 1 4 a 50 green 1 #> 2 2 2 3 a 100 green 5 #> 3 3 3 1 a 250 green 2"},{"path":"/reference/create_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a graph object — create_graph","title":"Create a graph object — create_graph","text":"Generates graph object option use node data frames (ndfs) /edge data frames (edfs) populate initial graph.","code":""},{"path":"/reference/create_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a graph object — create_graph","text":"","code":"create_graph( nodes_df = NULL, edges_df = NULL, directed = TRUE, graph_name = NULL, attr_theme = \"default\", write_backups = FALSE, display_msgs = FALSE )"},{"path":"/reference/create_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a graph object — create_graph","text":"nodes_df optional data frame containing, minimum, column (called id) contains node IDs graph. Additional columns (node attributes) can included values named node attribute. edges_df optional data frame containing, minimum, two columns (called ) node IDs provided. Additional columns (edge attributes) can included values named edge attribute. directed TRUE (default) FALSE, either directed undirected edge operations generated, respectively. graph_name optional string labeling graph object. attr_theme theme (.e., collection graph, node, edge global graph attributes) use graph. default theme called default; hierarchical layout themes called lr, tb, rl, bt (operate left--right, top--bottom, right--left, bottom--top); , larger graphs, fdp theme provides force directed layout. set NULL global graph attributes applied graph upon creation. write_backups option write incremental backups changing graph states disk. TRUE, subdirectory within working directory created used store RDS files. default value FALSE one opt use functionality. display_msgs option display messages primarily concerned changes graph selections. default, FALSE.","code":""},{"path":"/reference/create_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a graph object — create_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/create_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a graph object — create_graph","text":"","code":"# With `create_graph()` we can # simply create an empty graph (and # add in nodes and edges later # with other functions) graph <- create_graph() # A graph can be created with # nodes and without having any edges; # this can be done in 2 steps: # 1. create a node data frame (ndf) # using `create_node_df()` ndf <- create_node_df(n = 4) # 2. create a new graph object with # `create_graph()` and then pass # in the ndf to `nodes_df` graph <- create_graph( nodes_df = ndf) # Get information on the graph's nodes graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 0 0 0 0 #> 2 2 0 0 0 0 #> 3 3 0 0 0 0 #> 4 4 0 0 0 0 # You can create a similar graph with # just nodes but also providing a # range of attributes for the nodes # (e.g., types, labels, or arbitrary # 'values') ndf <- create_node_df( n = 4, label = TRUE, type = c(\"type_1\", \"type_1\", \"type_5\", \"type_2\"), shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), values = c(3.5, 2.6, 9.4, 2.7)) graph <- create_graph(nodes_df = ndf) # Get information on the graph's # internal node data frame (ndf) graph %>% get_node_df() #> id type label shape values #> 1 1 type_1 1 circle 3.5 #> 2 2 type_1 2 circle 2.6 #> 3 3 type_5 3 rectangle 9.4 #> 4 4 type_2 4 rectangle 2.7 # A graph can also be created by # specifying both the nodes and # edges; create an edge data frame # (edf) using the `create_edge_df()` # function: edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\", values = c(7.3, 2.6, 8.3)) # Create the graph object with # `create_graph()` and pass in the # ndf and edf objects graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get information on the graph's # internal edge data frame (edf) graph %>% get_edge_df() #> id from to rel values #> 1 1 1 4 leading_to 7.3 #> 2 2 2 3 leading_to 2.6 #> 3 3 3 1 leading_to 8.3 # Get information on the graph's # internal node data frame (ndf) graph %>% get_node_df() #> id type label shape values #> 1 1 type_1 1 circle 3.5 #> 2 2 type_1 2 circle 2.6 #> 3 3 type_5 3 rectangle 9.4 #> 4 4 type_2 4 rectangle 2.7"},{"path":"/reference/create_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a graph series object — create_graph_series","title":"Create a graph series object — create_graph_series","text":"Create graph series object storage multiple graphs across sequential temporal one-dimensional array.","code":""},{"path":"/reference/create_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a graph series object — create_graph_series","text":"","code":"create_graph_series( graph = NULL, series_name = NULL, series_type = \"sequential\" )"},{"path":"/reference/create_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a graph series object — create_graph_series","text":"graph graph object add new graph series object. series_name optional name ascribe series. series_type Either sequential type (default) temporal type (requires date-time strings time zone codes supplied).","code":""},{"path":"/reference/create_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a graph series object — create_graph_series","text":"graph series object type dgr_graph_1D.","code":""},{"path":"/reference/create_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a graph series object — create_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Count the number of graphs # in the graph series series %>% count_graphs_in_graph_series() #> [1] 3"},{"path":"/reference/create_node_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a node data frame — create_node_df","title":"Create a node data frame — create_node_df","text":"Combine several vectors nodes attributes data frame, can combined similarly-generated data frames, , added graph object. node data frame, ndf, least following columns: id (type integer) type (type character) label (type character) arbitrary number additional columns containing aesthetic data attributes can part ndf, long follow aforementioned columns.","code":""},{"path":"/reference/create_node_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a node data frame — create_node_df","text":"","code":"create_node_df(n, type = NULL, label = NULL, ...)"},{"path":"/reference/create_node_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a node data frame — create_node_df","text":"n total number nodes include node data frame. type optional type node. label optional label node. ... One vectors associated node attributes.","code":""},{"path":"/reference/create_node_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a node data frame — create_node_df","text":"node data frame (ndf).","code":""},{"path":[]},{"path":"/reference/create_node_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a node data frame — create_node_df","text":"","code":"# Create a node data frame (ndf) where the labels # are equivalent to the node ID values (this is not # recommended); the `label` and `type` node # attributes will always be a `character` class # whereas `id` will always be an `integer` node_df <- create_node_df( n = 4, type = c(\"a\", \"a\", \"b\", \"b\"), label = TRUE) # Display the node data frame node_df #> id type label #> 1 1 a 1 #> 2 2 a 2 #> 3 3 b 3 #> 4 4 b 4 # Create an ndf with distinct labels and # additional node attributes (where their classes # will be inferred from the input vectors) node_df <- create_node_df( n = 4, type = \"a\", label = c(2384, 3942, 8362, 2194), style = \"filled\", color = \"aqua\", shape = c(\"circle\", \"circle\", \"rectangle\", \"rectangle\"), value = c(3.5, 2.6, 9.4, 2.7)) # Display the node data frame node_df #> id type label style color shape value #> 1 1 a 2384 filled aqua circle 3.5 #> 2 2 a 3942 filled aqua circle 2.6 #> 3 3 a 8362 filled aqua rectangle 9.4 #> 4 4 a 2194 filled aqua rectangle 2.7"},{"path":"/reference/currencies.html","id":null,"dir":"Reference","previous_headings":"","what":"ISO-4217 currency data. — currencies","title":"ISO-4217 currency data. — currencies","text":"dataset containing currency information ISO-4217 standard.","code":""},{"path":"/reference/currencies.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ISO-4217 currency data. — currencies","text":"","code":"currencies"},{"path":"/reference/currencies.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ISO-4217 currency data. — currencies","text":"data frame 171 rows 4 variables: iso_4217_code three-letter currency code according ISO-4217 standard curr_number three-digit code number assigned currency ISO-4217 standard exponent base 10 exponent minor currency unit relation major currency unit (can assumed also number decimal places commonly considered currency) currency_name English name currency","code":""},{"path":"/reference/currencies.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ISO-4217 currency data. — currencies","text":"https://en.wikipedia.org/wiki/ISO_4217","code":""},{"path":"/reference/delete_cache.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete vectors cached in a graph object — delete_cache","title":"Delete vectors cached in a graph object — delete_cache","text":"Delete vectors cached graph object class dgr_graph.","code":""},{"path":"/reference/delete_cache.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete vectors cached in a graph object — delete_cache","text":"","code":"delete_cache(graph, name = NULL)"},{"path":"/reference/delete_cache.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete vectors cached in a graph object — delete_cache","text":"graph graph object class dgr_graph. name One name vector objects delete cache. none supplied, cached vectors available graph deleted.","code":""},{"path":"/reference/delete_cache.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete vectors cached in a graph object — delete_cache","text":"vector.","code":""},{"path":"/reference/delete_cache.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete vectors cached in a graph object — delete_cache","text":"","code":"# Create an empty graph graph <- create_graph() # Cache 3 different vectors inside # the graph object graph <- graph %>% set_cache( name = \"a\", to_cache = 1:4) %>% set_cache( name = \"b\", to_cache = 5:9) %>% set_cache( name = \"c\", to_cache = 10:14) # Delete cache `b` graph <- graph %>% delete_cache(name = \"b\") # Delete remaining cached vectors graph <- graph %>% delete_cache()"},{"path":"/reference/delete_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete an edge from an existing graph object — delete_edge","title":"Delete an edge from an existing graph object — delete_edge","text":"graph object class dgr_graph, delete existing edge specifying either: (1) pair node IDs corresponding edge (keeping consideration direction edge directed graph), (2) edge ID.","code":""},{"path":"/reference/delete_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete an edge from an existing graph object — delete_edge","text":"","code":"delete_edge(graph, from = NULL, to = NULL, id = NULL)"},{"path":"/reference/delete_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete an edge from an existing graph object — delete_edge","text":"graph graph object class dgr_graph. node ID edge removed outgoing. edge ID provided id, argument ignored. option use node label value (must correspondingly also done argument) defining node connections. Note possible nodes distinct label values set none exist empty string. node ID edge removed incoming. edge ID provided id, argument ignored. option use node label value (must correspondingly also argument) defining node connections. Note possible nodes distinct label values set none exist empty string. id edge ID edge removed.","code":""},{"path":"/reference/delete_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete an edge from an existing graph object — delete_edge","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete an edge from an existing graph object — delete_edge","text":"","code":"# Create a graph with 2 nodes graph <- create_graph() %>% add_n_nodes(n = 2) # Add an edge graph <- graph %>% add_edge( from = 1, to = 2) # Delete the edge graph <- graph %>% delete_edge( from = 1, to = 2) # Get the count of edges in the graph graph %>% count_edges() #> [1] 0 # Create an undirected graph with # 2 nodes and an edge graph_undirected <- create_graph(directed = FALSE) %>% add_n_nodes(n = 2) %>% add_edge( from = 1, to = 2) # Delete the edge; the order of node ID # values provided in `from` and `to` # don't matter for the undirected case graph_undirected %>% delete_edge( from = 2, to = 1) %>% count_edges() #> [1] 0 # The undirected graph has a single # edge with ID `1`; it can be # deleted by specifying `id` graph_undirected %>% delete_edge(id = 1) %>% count_edges() #> [1] 0 # Create a directed graph with 2 # labeled nodes and an edge graph_labeled_nodes <- create_graph() %>% add_n_nodes( n = 2, label = c(\"one\", \"two\")) %>% add_edge( from = \"one\", to = \"two\") # Delete the edge using the node # labels in `from` and `to`; this # is analogous to creating the # edge using node labels graph_labeled_nodes %>% delete_edge( from = \"one\", to = \"two\") %>% count_edges() #> [1] 0"},{"path":"/reference/delete_edges_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete all selected edges in an edge selection — delete_edges_ws","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"graph object class dgr_graph, delete edges present selection. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/delete_edges_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"","code":"delete_edges_ws(graph)"},{"path":"/reference/delete_edges_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/delete_edges_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_edges_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete all selected edges in an edge selection — delete_edges_ws","text":"","code":"# Create a graph graph <- create_graph() %>% add_n_nodes(n = 3) %>% add_edges_w_string( edges = \"1->3 1->2 2->3\") # Select edges attached to # node with ID `3` (these are # `1`->`3` and `2`->`3`) graph <- graph %>% select_edges_by_node_id(nodes = 3) # Delete edges in selection graph <- graph %>% delete_edges_ws() # Get a count of edges in the graph graph %>% count_edges() #> [1] 1"},{"path":"/reference/delete_global_graph_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"Delete one global attributes stored within graph object class dgr_graph).","code":""},{"path":"/reference/delete_global_graph_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"","code":"delete_global_graph_attrs(graph, attr = NULL, attr_type = NULL)"},{"path":"/reference/delete_global_graph_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"graph graph object class dgr_graph. attr name attribute delete type global attribute specified. attr_type specific type global graph attribute delete. type specified graph, node, edge.","code":""},{"path":"/reference/delete_global_graph_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"graph object class dgr_graph.","code":""},{"path":"/reference/delete_global_graph_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete one of the global graph attributes stored within a graph object — delete_global_graph_attrs","text":"","code":"# Create a new graph and add # some extra global graph attrs graph <- create_graph() %>% add_global_graph_attrs( attr = \"overlap\", value = \"true\", attr_type = \"graph\") %>% add_global_graph_attrs( attr = \"penwidth\", value = 3, attr_type = \"node\") %>% add_global_graph_attrs( attr = \"penwidth\", value = 3, attr_type = \"edge\") # Inspect the graph's global # attributes graph %>% get_global_graph_attr_info() #> # A tibble: 20 × 3 #> attr value attr_type #> #> 1 layout neato graph #> 2 outputorder edgesfirst graph #> 3 bgcolor white graph #> 4 fontname Helvetica node #> 5 fontsize 10 node #> 6 shape circle node #> 7 fixedsize true node #> 8 width 0.5 node #> 9 style filled node #> 10 fillcolor aliceblue node #> 11 color gray70 node #> 12 fontcolor gray50 node #> 13 fontname Helvetica edge #> 14 fontsize 8 edge #> 15 len 1.5 edge #> 16 color gray80 edge #> 17 arrowsize 0.5 edge #> 18 overlap true graph #> 19 penwidth 3 node #> 20 penwidth 3 edge # Delete the `penwidth` attribute # for the graph's nodes using the # `delete_global_graph_attrs()` fcn graph <- graph %>% delete_global_graph_attrs( attr = \"penwidth\", attr_type = \"node\") # View the remaining set of global # attributes for the graph graph %>% get_global_graph_attr_info() #> # A tibble: 19 × 3 #> attr value attr_type #> #> 1 layout neato graph #> 2 outputorder edgesfirst graph #> 3 bgcolor white graph #> 4 fontname Helvetica node #> 5 fontsize 10 node #> 6 shape circle node #> 7 fixedsize true node #> 8 width 0.5 node #> 9 style filled node #> 10 fillcolor aliceblue node #> 11 color gray70 node #> 12 fontcolor gray50 node #> 13 fontname Helvetica edge #> 14 fontsize 8 edge #> 15 len 1.5 edge #> 16 color gray80 edge #> 17 arrowsize 0.5 edge #> 18 overlap true graph #> 19 penwidth 3 edge"},{"path":"/reference/delete_graph_actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete one or more graph actions stored within a graph object — delete_graph_actions","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"Delete one graph actions stored within graph object class dgr_graph).","code":""},{"path":"/reference/delete_graph_actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"","code":"delete_graph_actions(graph, actions)"},{"path":"/reference/delete_graph_actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"graph graph object class dgr_graph. actions Either vector integer numbers indicating actions delete (based action_index values), , character vector corresponding action_name values.","code":""},{"path":"/reference/delete_graph_actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"graph object class dgr_graph.","code":""},{"path":"/reference/delete_graph_actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete one or more graph actions stored within a graph object — delete_graph_actions","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 8, set_seed = 23) # Add three graph actions to the # graph graph <- graph %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\", action_name = \"get_pagerank\") %>% add_graph_action( fcn = \"rescale_node_attrs\", node_attr_from = \"pagerank\", node_attr_to = \"width\", action_name = \"pagerank_to_width\") %>% add_graph_action( fcn = \"colorize_node_attrs\", node_attr_from = \"width\", node_attr_to = \"fillcolor\", action_name = \"pagerank_fillcolor\") # View the graph actions for the graph # object by using the `get_graph_actions()` # function graph %>% get_graph_actions() #> # A tibble: 3 × 3 #> action_index action_name expression #> #> 1 1 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_… #> 2 2 pagerank_to_width rescale_node_attrs(graph = graph, node_attr_f… #> 3 3 pagerank_fillcolor colorize_node_attrs(graph = graph, node_attr_… # Delete the second and third graph # actions using `delete_graph_actions()` graph <- graph %>% delete_graph_actions( actions = c(2, 3)) # Verify that these last two graph # actions were deleted by again using # the `get_graph_actions()` function graph %>% get_graph_actions() #> # A tibble: 1 × 3 #> action_index action_name expression #> #> 1 1 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_fcn = …"},{"path":"/reference/delete_loop_edges_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"selection nodes graph, remove associated loop edges. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/delete_loop_edges_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"","code":"delete_loop_edges_ws(graph)"},{"path":"/reference/delete_loop_edges_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/delete_loop_edges_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_loop_edges_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete all loop edges associated with a selection of nodes — delete_loop_edges_ws","text":"","code":"# Create an undirected, full graph # of 5 nodes with loops retained graph <- create_graph( directed = FALSE) %>% add_full_graph( n = 5, keep_loops = TRUE) # Select nodes `3` and `4` # and remove the loop edges # associated with those nodes graph <- graph %>% select_nodes_by_id( nodes = 3:4) %>% delete_loop_edges_ws() # Count the number of loop # edges remaining in the graph graph %>% count_loop_edges() #> [1] 3"},{"path":"/reference/delete_node.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete a node from an existing graph object — delete_node","title":"Delete a node from an existing graph object — delete_node","text":"graph object class dgr_graph, delete existing node specifying node ID.","code":""},{"path":"/reference/delete_node.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete a node from an existing graph object — delete_node","text":"","code":"delete_node(graph, node)"},{"path":"/reference/delete_node.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete a node from an existing graph object — delete_node","text":"graph graph object class dgr_graph. node node ID node deleted graph.","code":""},{"path":"/reference/delete_node.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete a node from an existing graph object — delete_node","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_node.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete a node from an existing graph object — delete_node","text":"","code":"# Create a graph with 5 nodes and # edges between each in a path graph <- create_graph() %>% add_path(n = 5) # Delete node with ID `3` graph <- delete_node(graph, node = 3) # Verify that the node with ID `3` # is no longer in the graph graph %>% get_node_ids() #> [1] 1 2 4 5 # Also note that edges are removed # since there were edges between the # removed node to and from other nodes graph %>% get_edges() #> [1] \"1->2\" \"4->5\""},{"path":"/reference/delete_nodes_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Delete all nodes in a node selection — delete_nodes_ws","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"graph object class dgr_graph, delete nodes present selection nodes. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/delete_nodes_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"","code":"delete_nodes_ws(graph)"},{"path":"/reference/delete_nodes_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/delete_nodes_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/delete_nodes_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Delete all nodes in a node selection — delete_nodes_ws","text":"","code":"# Create a graph with 3 nodes graph <- create_graph() %>% add_n_nodes(n = 3) %>% add_edges_w_string( edges = \"1->3 1->2 2->3\") # Select node with ID `1` graph <- graph %>% select_nodes_by_id(nodes = 1) # Delete node in selection (this # also deletes any attached edges) graph <- graph %>% delete_nodes_ws() # Get a count of nodes in the graph graph %>% count_nodes() #> [1] 2"},{"path":"/reference/deselect_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Deselect any selected edges in a graph — deselect_edges","title":"Deselect any selected edges in a graph — deselect_edges","text":"Deselect edges graph object class dgr_graph.","code":""},{"path":"/reference/deselect_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Deselect any selected edges in a graph — deselect_edges","text":"","code":"deselect_edges(graph, edges)"},{"path":"/reference/deselect_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Deselect any selected edges in a graph — deselect_edges","text":"graph graph object class dgr_graph. edges vector edge IDs deselected.","code":""},{"path":"/reference/deselect_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Deselect any selected edges in a graph — deselect_edges","text":"graph object class dgr_graph.","code":""},{"path":"/reference/deselect_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Deselect any selected edges in a graph — deselect_edges","text":"","code":"# Create a graph with # a single path graph <- create_graph() %>% add_path(n = 5) # Select edges with IDs `1` # and `3` graph <- graph %>% select_edges_by_edge_id( edges = c(1, 3)) # Verify that an edge selection # has been made graph %>% get_selection() #> [1] 1 3 # Deselect edge `1` graph <- graph %>% select_edges_by_edge_id( edges = c(1, 3)) %>% deselect_edges(edges = 1) # Verify that the edge selection # has been made for edges `1` and # `3` and that edge `1` has been # deselected (leaving only `3`) graph %>% get_selection() #> [1] 3"},{"path":"/reference/deselect_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Deselect any selected nodes in a graph — deselect_nodes","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"Deselect nodes graph object class dgr_graph.","code":""},{"path":"/reference/deselect_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"","code":"deselect_nodes(graph, nodes)"},{"path":"/reference/deselect_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"graph graph object class dgr_graph. nodes vector node IDs deselected.","code":""},{"path":"/reference/deselect_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"graph object class dgr_graph.","code":""},{"path":"/reference/deselect_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Deselect any selected nodes in a graph — deselect_nodes","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = c(\"a\", \"a\", \"z\", \"z\"), label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = c(\"a\", \"z\", \"a\")) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Explicitly select nodes `1` and `3` graph <- graph %>% select_nodes(nodes = c(1, 3)) %>% deselect_nodes(nodes = 1) # Verify that the node selection # has been made for nodes `1` and # `3` and that node `1` has been # deselected (leaving only `3`) graph %>% get_selection() #> [1] 3"},{"path":"/reference/display_metagraph.html","id":null,"dir":"Reference","previous_headings":"","what":"Display a property graph's underlying model — display_metagraph","title":"Display a property graph's underlying model — display_metagraph","text":"graph object class dgr_graph also property graph (.e., nodes assigned type value edges assigned rel value), display metagraph RStudio Viewer. representation provides combinations edges different rel values nodes distinct type values, including edges nodes type (shown loops). precondition graph property graph can verified using is_property_graph() function.","code":""},{"path":"/reference/display_metagraph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Display a property graph's underlying model — display_metagraph","text":"","code":"display_metagraph(graph)"},{"path":"/reference/display_metagraph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Display a property graph's underlying model — display_metagraph","text":"graph graph object class dgr_graph. graph must fulfill condition property graph, otherwise function yields error.","code":""},{"path":"/reference/display_metagraph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Display a property graph's underlying model — display_metagraph","text":"","code":"# Create a randomized property # graph with 1000 nodes and 1350 edges property_graph <- create_graph() %>% add_gnm_graph( n = 1000, m = 1350, set_seed = 23) %>% select_nodes_by_degree( expressions = \"deg >= 3\") %>% set_node_attrs_ws( node_attr = type, value = \"a\") %>% clear_selection() %>% select_nodes_by_degree( expressions = \"deg < 3\") %>% set_node_attrs_ws( node_attr = type, value = \"b\") %>% clear_selection() %>% select_nodes_by_degree( expressions = \"deg == 0\") %>% set_node_attrs_ws( node_attr = type, value = \"c\") %>% set_node_attr_to_display( attr = type) %>% select_edges_by_node_id( nodes = get_node_ids(.) %>% sample( size = 0.15 * length(.) %>% floor())) %>% set_edge_attrs_ws( edge_attr = rel, value = \"r_1\") %>% invert_selection() %>% set_edge_attrs_ws( edge_attr = rel, value = \"r_2\") %>% clear_selection() %>% copy_edge_attrs( edge_attr_from = rel, edge_attr_to = label) %>% add_global_graph_attrs( attr = \"fontname\", value = \"Helvetica\", attr_type = \"edge\") %>% add_global_graph_attrs( attr = \"fontcolor\", value = \"gray50\", attr_type = \"edge\") %>% add_global_graph_attrs( attr = \"fontsize\", value = 10, attr_type = \"edge\") # Display this graph's # metagraph, or, the underlying # graph model for a property graph # display_metagraph(property_graph)"},{"path":"/reference/do_bfs.html","id":null,"dir":"Reference","previous_headings":"","what":"Use the breadth-first search (bfs) algorithm — do_bfs","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"chosen random node serving starting point, perform breadth-first search whole graph return node ID values visited. bfs algorithm differs depth-first search (dfs) bfs follow tree branches branches one level time terminating leaf node (dfs traverses branches far possible).","code":""},{"path":"/reference/do_bfs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"","code":"do_bfs(graph, node = NULL, direction = \"all\")"},{"path":"/reference/do_bfs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"graph graph object class dgr_graph. node optional node ID value specify single starting point bfs. provided, random node graph chosen. direction Using (default), bfs ignore edge direction traversing graph. , traversals adjacent nodes respect edge direction.","code":""},{"path":"/reference/do_bfs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"vector containing node ID values nodes visited breadth-first search. order node IDs corresponds order visited.","code":""},{"path":"/reference/do_bfs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Use the breadth-first search (bfs) algorithm — do_bfs","text":"","code":"# Create a graph containing # two balanced trees graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) %>% add_balanced_tree( k = 3, h = 2) # Perform a breadth-first # search of the graph, # beginning at the root node # `1` (the default # `direction = \"all\"` doesn't # take edge direction into # account) graph %>% do_bfs(node = 1) #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # If not specifying a # starting node, the function # will begin the search from # a random node graph %>% do_bfs() #> [1] 9 8 12 13 14 10 11 15 16 17 18 19 20 1 2 3 4 5 6 7 # It's also possible to # perform bfs while taking # into account edge direction; # using `direction = \"in\"` # causes the bfs routine to # visit nodes along inward edges graph %>% do_bfs( node = 1, direction = \"in\") #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # Using `direction = \"out\"` # results in the bfs moving # along solely outward edges graph %>% do_bfs( node = 1, direction = \"out\") #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"},{"path":"/reference/do_dfs.html","id":null,"dir":"Reference","previous_headings":"","what":"Use the depth-first search (dfs) algorithm — do_dfs","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"chosen random node serving starting point, perform depth-first search whole graph return node ID values visited. dfs algorithm differs breadth-first search (bfs) dfs follow tree branches far possible terminating leaf node (bfs traverses branches one level time).","code":""},{"path":"/reference/do_dfs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"","code":"do_dfs(graph, node = NULL, direction = \"all\")"},{"path":"/reference/do_dfs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"graph graph object class dgr_graph. node optional node ID value specify single starting point dfs. provided, random node graph chosen. direction Using (default), bfs ignore edge direction traversing graph. , traversals adjacent nodes respect edge direction.","code":""},{"path":"/reference/do_dfs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"vector containing node ID values nodes visited depth-first search. order node IDs corresponds order visited.","code":""},{"path":"/reference/do_dfs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Use the depth-first search (dfs) algorithm — do_dfs","text":"","code":"# Create a graph containing # two balanced trees graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) %>% add_balanced_tree( k = 3, h = 2) # Perform a depth-first # search of the graph, # beginning at the root # node `1` (the default # `direction = \"all\"` # doesn't take edge # direction into account) graph %>% do_dfs(node = 1) #> [1] 1 2 4 5 3 6 7 8 9 12 13 14 10 15 16 17 11 18 19 20 # If not specifying a # starting node, the function # will begin the search # from a random node graph %>% do_dfs() #> [1] 2 1 3 6 7 4 5 8 9 12 13 14 10 15 16 17 11 18 19 20 # It's also possible to # perform dfs while taking # into account edge direction; # using `direction = \"in\"` # causes the dfs routine to # visit nodes along inward edges graph %>% do_dfs( node = 1, direction = \"in\") #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # Using `direction = \"out\"` # results in the dfs moving # along solely outward edges graph %>% do_dfs( node = 1, direction = \"out\") #> [1] 1 2 4 5 3 6 7 8 9 12 13 14 10 15 16 17 11 18 19 20"},{"path":"/reference/drop_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Drop an edge attribute column — drop_edge_attrs","title":"Drop an edge attribute column — drop_edge_attrs","text":"Within graph's internal edge data frame (edf), remove existing edge attribute.","code":""},{"path":"/reference/drop_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drop an edge attribute column — drop_edge_attrs","text":"","code":"drop_edge_attrs(graph, edge_attr)"},{"path":"/reference/drop_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Drop an edge attribute column — drop_edge_attrs","text":"graph graph object class dgr_graph. edge_attr name edge attribute column drop.","code":""},{"path":"/reference/drop_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Drop an edge attribute column — drop_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/drop_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Drop an edge attribute column — drop_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 6, set_seed = 23) %>% set_edge_attrs( edge_attr = value, values = 3) %>% mutate_edge_attrs( penwidth = value * 2) # Get the graph's internal # edf to show which edge # attributes are available graph %>% get_edge_df() #> id from to rel value penwidth #> 1 1 1 4 3 6 #> 2 2 2 3 3 6 #> 3 3 2 4 3 6 #> 4 4 3 1 3 6 #> 5 5 4 1 3 6 #> 6 6 5 4 3 6 # Drop the `value` edge # attribute graph <- graph %>% drop_edge_attrs( edge_attr = value) # Get the graph's internal # edf to show that the edge # attribute `value` had been # removed graph %>% get_edge_df() #> id from to rel penwidth #> 1 1 1 4 6 #> 2 2 2 3 6 #> 3 3 2 4 6 #> 4 4 3 1 6 #> 5 5 4 1 6 #> 6 6 5 4 6"},{"path":"/reference/drop_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Drop a node attribute column — drop_node_attrs","title":"Drop a node attribute column — drop_node_attrs","text":"Within graph's internal node data frame (ndf), remove existing node attribute.","code":""},{"path":"/reference/drop_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drop a node attribute column — drop_node_attrs","text":"","code":"drop_node_attrs(graph, node_attr)"},{"path":"/reference/drop_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Drop a node attribute column — drop_node_attrs","text":"graph graph object class dgr_graph. node_attr name node attribute column drop.","code":""},{"path":"/reference/drop_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Drop a node attribute column — drop_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/drop_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Drop a node attribute column — drop_node_attrs","text":"","code":"graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the graph's internal # ndf to show which node # attributes are available graph %>% get_node_df() #> id type label value #> 1 1 1 5.3 #> 2 2 2 4.4 #> 3 3 3 5.8 #> 4 4 4 5.9 #> 5 5 5 6.2 # Drop the `value` node # attribute graph <- graph %>% drop_node_attrs( node_attr = value) # Get the graph's internal # ndf to show that the node # attribute `value` had been # removed graph %>% get_node_df() #> id type label #> 1 1 1 #> 2 2 2 #> 3 3 3 #> 4 4 4 #> 5 5 5"},{"path":"/reference/edge_aes.html","id":null,"dir":"Reference","previous_headings":"","what":"Insert edge aesthetic attributes during edge creation — edge_aes","title":"Insert edge aesthetic attributes during edge creation — edge_aes","text":"helper function invoked provide values namesake edge_aes argument, present function edges created.","code":""},{"path":"/reference/edge_aes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insert edge aesthetic attributes during edge creation — edge_aes","text":"","code":"edge_aes( style = NULL, penwidth = NULL, color = NULL, arrowsize = NULL, arrowhead = NULL, arrowtail = NULL, fontname = NULL, fontsize = NULL, fontcolor = NULL, len = NULL, tooltip = NULL, URL = NULL, label = NULL, labelfontname = NULL, labelfontsize = NULL, labelfontcolor = NULL, labeltooltip = NULL, labelURL = NULL, edgetooltip = NULL, edgeURL = NULL, dir = NULL, headtooltip = NULL, headURL = NULL, headclip = NULL, headlabel = NULL, headport = NULL, tailtooltip = NULL, tailURL = NULL, tailclip = NULL, taillabel = NULL, tailport = NULL, decorate = NULL )"},{"path":"/reference/edge_aes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insert edge aesthetic attributes during edge creation — edge_aes","text":"style edge line style. style types can used solid, bold, dashed, dotted, tapered, invisible. penwidth thickness stroke line edge . color color edge. Can X11 color hexadecimal color code. arrowsize scaling factor arrowheads. default value 1.0 minimum 0. arrowhead type arrowhead use. style attribute can types: normal, vee, tee, dot, diamond, box, curve, icurve, inv, crow, none. arrowtail type arrowtail use. style attribute can types: normal, vee, tee, dot, diamond, box, curve, icurve, inv, crow, none. fontname name system font used edge text. fontsize point size font used edge text. fontcolor color used edge text. Can X11 color hexadecimal color code. len preferred edge length edge, inches. Default value 1.0. tooltip Text tooltip appears hovering edge. text provided, default tooltip text provide edge definition (.e., [id]->[id] [id]--[id]). URL URL associate edge. Upon rendering plot, clicking edges associated URLs open URL default browser. label label text associated edge. text appear near center edge. labelfontname name system font used headlabel taillabel label text. set, fontname value instead used. labelfontsize point size font used headlabel taillabel label text. set, fontsize value instead used. labelfontcolor color used label text headlabel taillabel label text. set, fontcolor value instead used. Can X11 color hexadecimal color code. labeltooltip Text tooltip appear hovering main label edge (label text provided label edge attribute). text provided edge label visible, default tooltip text provide edge definition (.e., [id]->[id] [id]--[id]). labelURL URL associate edge label text. Upon rendering plot, clicking edge labels associated URLs open URL default browser. edgetooltip option provides means specify tooltip non-label parts edge. defined, value overrides tooltip defined edge. tooltip text hovering along edge (even near head tail node) unless overridden headtooltip tailtooltip value. edgeURL option provides means specify URL non-label parts edge. defined, value overrides URL defined edge. URL used along edge (even near head tail node) unless overridden headURL tailURL value. dir optional direction type. Normally, directed graphs, forward needn't set. undirected graphs, none explicit setting required. However, one can also use back options. back option draws arrowhead reverse direction edge. option draws two arrowheads. using options explicit manner, head... tail... edge attributes allow control aesthetic edge attributes either side edge. headtooltip option provides means specify tooltip can displayed hovering part edge adjacent incoming node (see tooltip argument details). headURL option provides means specify URL can accessed clicking part edge adjacent incoming node (see URL argument details). headclip TRUE (default behavior), head affected edge clipped node boundary. Using FALSE places head outgoing edge center node. headlabel option provides means display label near part edge adjacent incoming node (see label argument details). headport Allows one specify compass position incoming node head edge alight. Options n, ne, e, se, s, sw, w, nw. tailtooltip option provides means specify tooltip can displayed hovering part edge adjacent outgoing node (see tooltip argument details). tailURL option provides means specify URL can accessed clicking part edge adjacent outgoing node (see URL argument details). tailclip TRUE (default behavior), tail affected edge clipped node boundary. Using FALSE places tail outgoing edge center node. taillabel option provides means display label near part edge adjacent outgoing node (see label argument details). tailport Allows one specify compass position outgoing node tail edge emitted . Options n, ne, e, se, s, sw, w, nw. decorate TRUE attach edge label edge line via 2-segment polyline, underlining label text partially overlapping edge line.","code":""},{"path":[]},{"path":"/reference/edge_aes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insert edge aesthetic attributes during edge creation — edge_aes","text":"","code":"# Create a new graph and add # a path with several edge # aesthetic attributes graph <- create_graph() %>% add_path( n = 3, type = \"path\", edge_aes = edge_aes( style = \"dot\", color = c(\"red\", \"blue\"))) # View the graph's internal # node data frame; the node # aesthetic attributes have # been inserted graph %>% get_edge_df() #> id from to rel style color #> 1 1 1 2 dot red #> 2 2 2 3 dot blue"},{"path":"/reference/edge_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Insert edge data attributes during edge creation — edge_data","title":"Insert edge data attributes during edge creation — edge_data","text":"helper function invoked provide values namesake edge_data argument, present function edges created.","code":""},{"path":"/reference/edge_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insert edge data attributes during edge creation — edge_data","text":"","code":"edge_data(...)"},{"path":"/reference/edge_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insert edge data attributes during edge creation — edge_data","text":"... Edge data attributes provided one named vectors.","code":""},{"path":[]},{"path":"/reference/edge_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insert edge data attributes during edge creation — edge_data","text":"","code":"if (FALSE) { # Create a new graph and add # a path with several edge # data attributes graph <- create_graph() %>% add_path( n = 3, type = \"path\", edge_data = edge_data( hour = 5, index = c(1, 2))) # View the graph's internal # edge data frame; the edge # data attributes have # been inserted graph %>% get_edge_df() }"},{"path":"/reference/edge_list_1.html","id":null,"dir":"Reference","previous_headings":"","what":"Edge list - Version 1. — edge_list_1","title":"Edge list - Version 1. — edge_list_1","text":"simple, 2-column data frame can used generate graph edges.","code":""},{"path":"/reference/edge_list_1.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Edge list - Version 1. — edge_list_1","text":"","code":"edge_list_1"},{"path":"/reference/edge_list_1.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Edge list - Version 1. — edge_list_1","text":"data frame 19 rows 2 variables: integer values state node ID values edge starts integer values state node ID values edge terminates","code":""},{"path":"/reference/edge_list_2.html","id":null,"dir":"Reference","previous_headings":"","what":"Edge list - Version 2. — edge_list_2","title":"Edge list - Version 2. — edge_list_2","text":"simple, 5-column data frame can used generate graph edges.","code":""},{"path":"/reference/edge_list_2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Edge list - Version 2. — edge_list_2","text":"","code":"edge_list_2"},{"path":"/reference/edge_list_2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Edge list - Version 2. — edge_list_2","text":"data frame 19 rows 5 variables: integer values state node ID values edge starts integer values state node ID values edge terminates rel grouping variable either , b, c value_1 randomized set numeric values 0 10 value_2 randomized set numeric values 0 10","code":""},{"path":"/reference/export_csv.html","id":null,"dir":"Reference","previous_headings":"","what":"Export a graph to CSV files — export_csv","title":"Export a graph to CSV files — export_csv","text":"Export graph separate CSV files nodes edges.","code":""},{"path":"/reference/export_csv.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export a graph to CSV files — export_csv","text":"","code":"export_csv( graph, ndf_name = \"nodes.csv\", edf_name = \"edges.csv\", output_path = getwd(), colnames_type = NULL )"},{"path":"/reference/export_csv.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export a graph to CSV files — export_csv","text":"graph graph object class dgr_graph. ndf_name name provide CSV file containing node information. default CSV called nodes.csv. edf_name name provide CSV file containing edge information. default CSV called edges.csv. output_path path CSV files placed. default, current working directory. colnames_type Provides options modify CSV column names allow easier import graph systems. neo4j option modifies column names allow direct import CSVs Neo4J LOAD CSV clause. graphframes option modifies column names match required Spark GraphFrames package.","code":""},{"path":"/reference/export_csv.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export a graph to CSV files — export_csv","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = c(\"a\", \"a\", \"z\", \"z\"), label = TRUE, value = c(3.5, 2.6, 9.4, 2.7) ) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = c(\"rel_a\", \"rel_z\", \"rel_a\") ) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf ) # Create separate `nodes.csv` and # `edges.csv` files # graph %>% export_csv()"},{"path":"/reference/export_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Export a graph to various image formats — export_graph","title":"Export a graph to various image formats — export_graph","text":"Export graph variety image formats PNG, PDF, SVG, PostScript.","code":""},{"path":"/reference/export_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Export a graph to various image formats — export_graph","text":"","code":"export_graph( graph, file_name = NULL, file_type = NULL, title = NULL, width = NULL, height = NULL )"},{"path":"/reference/export_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Export a graph to various image formats — export_graph","text":"graph graph object class dgr_graph. file_name name exported file (including extension). file_type type file exported. Options graph files : png, pdf, svg, ps. title optional title output graph. width Output width pixels NULL default. useful export image file formats png, pdf, svg, ps. height Output height pixels NULL default. useful export image file formats png, pdf, svg, ps.","code":""},{"path":[]},{"path":"/reference/export_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Export a graph to various image formats — export_graph","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_path( n = 5, edge_aes = edge_aes( arrowhead = c( \"normal\", \"vee\", \"tee\", \"dot\" ), color = c( \"red\", \"blue\", \"orange\", \"purple\" ) ) ) # Create a PDF file for # the graph (`graph.pdf`) # graph %>% # export_graph( # file_name = \"graph.pdf\", # title = \"Simple Graph\" # ) # Create a PNG file for # the graph (`mypng.png`) # graph %>% # export_graph( # file_name = \"mypng.png\", # file_type = \"PNG\" # )"},{"path":"/reference/filter_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Subset a graph series object — filter_graph_series","title":"Subset a graph series object — filter_graph_series","text":"Subsetting graph series graphs' index positions graph series selection via graphs' date-time attributes.","code":""},{"path":"/reference/filter_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Subset a graph series object — filter_graph_series","text":"","code":"filter_graph_series(graph_series, by = \"number\", values, tz = NULL)"},{"path":"/reference/filter_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Subset a graph series object — filter_graph_series","text":"graph_series graph series object type dgr_graph_1D. Either number, allows subsetting graph series graph indices, time graph series objects type temporal allows subsetting graphs date-time time range. values subsetting graph series occur via graph indices (= number), provide vector indices; subsetting time (= time), range times can provided vector. tz time zone (tz) corresponding dates date-time string provided values (= \"date\").","code":""},{"path":"/reference/filter_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Subset a graph series object — filter_graph_series","text":"graph series object type dgr_graph_1D.","code":""},{"path":"/reference/filter_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Subset a graph series object — filter_graph_series","text":"","code":"# Create three graphs graph_time_1 <- create_graph( graph_name = \"graph_with_time_1\") %>% set_graph_time( time = \"2015-03-25 03:00\", tz = \"GMT\") graph_time_2 <- create_graph( graph_name = \"graph_with_time_2\") %>% set_graph_time( time = \"2015-03-26 03:00\", tz = \"GMT\") graph_time_3 <- create_graph( graph_name = \"graph_with_time_3\") %>% set_graph_time( time = \"2015-03-27 15:00\", tz = \"GMT\") # Create an empty graph series and add # the graphs series_temporal <- create_graph_series( series_type = \"temporal\") %>% add_graph_to_graph_series( graph = graph_time_1) %>% add_graph_to_graph_series( graph = graph_time_2) %>% add_graph_to_graph_series( graph = graph_time_3) # Subset graph series by sequence series_sequence_subset <- filter_graph_series( graph_series = series_temporal, by = \"number\", values = 2) # Get a count of graphs in # the series series_sequence_subset %>% count_graphs_in_graph_series() #> [1] 1 # Subset graph series by date-time series_time_subset <- filter_graph_series( graph_series = series_temporal, by = \"time\", values = c(\"2015-03-25 12:00\", \"2015-03-26 12:00\"), tz = \"GMT\") # Get a count of graphs in # the series series_time_subset %>% count_graphs_in_graph_series() #> [1] 2"},{"path":"/reference/from_adj_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a graph using an adjacency matrix — from_adj_matrix","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"Using adjacency matrix object, generate graph class dgr_graph.","code":""},{"path":"/reference/from_adj_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"","code":"from_adj_matrix( x, mode = \"undirected\", weighted = FALSE, use_diag = TRUE, graph_name = NULL, write_backups = FALSE, display_msgs = FALSE )"},{"path":"/reference/from_adj_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"x square matrix object serving adjacency matrix. mode method interpret input adjacency matrix. Options include: undirected, directed, upper, lower, max, min, plus. weighted Whether create weighted graph adjacency matrix. use_diag Whether use diagonal adjacency matrix calculations. TRUE diagonal values included . FALSE diagonal values replaced zero values inclusion calculations. graph_name optional string labeling graph object. write_backups option write incremental backups changing graph states disk. TRUE, subdirectory within working directory created used store RDS files. default value FALSE one opt use functionality. display_msgs option display messages primarily concerned changes graph selections. default, FALSE.","code":""},{"path":"/reference/from_adj_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"graph object class dgr_graph.","code":""},{"path":"/reference/from_adj_matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a graph using an adjacency matrix — from_adj_matrix","text":"","code":"# Create an adjacency matrix adj_matrix <- sample( 0:1, 100, replace = TRUE, prob = c(0.9,0.1) ) %>% matrix(ncol = 10) # Create a graph from the adjacency matrix graph <- from_adj_matrix(adj_matrix)"},{"path":"/reference/from_igraph.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an igraph graph to a DiagrammeR one — from_igraph","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"Convert igraph graph DiagrammeR graph object.","code":""},{"path":"/reference/from_igraph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"","code":"from_igraph( igraph, graph_name = NULL, write_backups = FALSE, display_msgs = FALSE )"},{"path":"/reference/from_igraph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"igraph igraph graph object. graph_name optional string labeling graph object. write_backups option write incremental backups changing graph states disk. TRUE, subdirectory within working directory created used store RDS files. default value FALSE one opt use functionality. display_msgs option display messages primarily concerned changes graph selections. default, FALSE.","code":""},{"path":"/reference/from_igraph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/from_igraph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert an igraph graph to a DiagrammeR one — from_igraph","text":"","code":"# Create a DiagrammeR graph object dgr_graph_orig <- create_graph() %>% add_gnm_graph( n = 36, m = 50, set_seed = 23) # Convert the DiagrammeR # graph to an igraph object ig_graph <- dgr_graph_orig %>% to_igraph() # Convert the igraph graph # back to a DiagrammeR graph dgr_graph_new <- ig_graph %>% from_igraph() # Get some graph information (dgr_graph_new %>% get_graph_info())[, 1:6] #> name n e dens mn_deg mx_deg #> 1 graph_hWHYG7a9 36 50 0.0571 1 7"},{"path":"/reference/fully_connect_nodes_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"selection nodes graph, add remaining edges required fully connect group edges . function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/fully_connect_nodes_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"","code":"fully_connect_nodes_ws(graph)"},{"path":"/reference/fully_connect_nodes_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/fully_connect_nodes_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"graph object class dgr_graph.","code":""},{"path":"/reference/fully_connect_nodes_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fully connect all nodes in a selection of nodes — fully_connect_nodes_ws","text":"","code":"# Create an empty graph and # then add a path of 3 nodes # and two isolated nodes graph <- create_graph() %>% add_path(n = 3) %>% add_n_nodes(n = 2) # Select a node in the path # of nodes (node `3`) and # the two isolated nodes (`4` # and `5`); then, and fully # connect these nodes together graph <- graph %>% select_nodes_by_id( nodes = 3:5) %>% fully_connect_nodes_ws() # Get the graph's edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 3 5 #> 5 5 4 5 #> 6 6 4 3 #> 7 7 5 3 #> 8 8 5 4 # Create an undirected, empty # graph; add a path of 3 nodes # and two isolated nodes graph <- create_graph( directed = FALSE) %>% add_path(n = 3) %>% add_n_nodes(n = 2) # Select a node in the path # of nodes (node `3`) and # the two isolated nodes (`4` # and `5`); then, and fully # connect these nodes together graph <- graph %>% select_nodes_by_id( nodes = 3:5) %>% fully_connect_nodes_ws() # Get the graph's edge data # frame; in the undirected # case, reverse edges aren't # added graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 3 5 #> 5 5 4 5 "},{"path":"/reference/fully_disconnect_nodes_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"selection nodes graph, remove edges nodes.","code":""},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"","code":"fully_disconnect_nodes_ws(graph)"},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"graph object class dgr_graph.","code":""},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/fully_disconnect_nodes_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Fully disconnect all nodes in a selection of nodes — fully_disconnect_nodes_ws","text":"","code":"# Create an empty graph and # add a path of 6 nodes graph <- create_graph() %>% add_path(n = 6) # Select nodes `3` and `4` # and fully disconnect them # from the graph graph <- graph %>% select_nodes_by_id( nodes = 3:4) %>% fully_disconnect_nodes_ws() # Get the graph's edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 5 5 6 "},{"path":"/reference/generate_dot.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate DOT code using a graph object — generate_dot","title":"Generate DOT code using a graph object — generate_dot","text":"Generates Graphviz DOT code R character object using DiagrammeR graph object.","code":""},{"path":"/reference/generate_dot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate DOT code using a graph object — generate_dot","text":"","code":"generate_dot(graph)"},{"path":"/reference/generate_dot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate DOT code using a graph object — generate_dot","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/generate_dot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate DOT code using a graph object — generate_dot","text":"character vector length 1 containing Graphviz DOT code.","code":""},{"path":"/reference/get_adhesion.html","id":null,"dir":"Reference","previous_headings":"","what":"Get graph adhesion — get_adhesion","title":"Get graph adhesion — get_adhesion","text":"Get adhesion graph, minimum number edges needed remove obtain graph strongly connected. edge connectivity graph.","code":""},{"path":"/reference/get_adhesion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get graph adhesion — get_adhesion","text":"","code":"get_adhesion(graph)"},{"path":"/reference/get_adhesion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get graph adhesion — get_adhesion","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_adhesion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get graph adhesion — get_adhesion","text":"single numeric value representing minimum number edges remove.","code":""},{"path":"/reference/get_adhesion.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get graph adhesion — get_adhesion","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the graph's adhesion graph %>% get_adhesion() #> [1] 1 # Create a full graph and then # get the adhesion for that create_graph() %>% add_full_graph(n = 8) %>% get_adhesion() #> [1] 7"},{"path":"/reference/get_agg_degree_in.html","id":null,"dir":"Reference","previous_headings":"","what":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"Get single, aggregate value indegree values nodes graph, , subset graph nodes.","code":""},{"path":"/reference/get_agg_degree_in.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"","code":"get_agg_degree_in(graph, agg, conditions = NULL)"},{"path":"/reference/get_agg_degree_in.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"graph graph object class dgr_graph. agg aggregation function use summarizing indegree values graph nodes. following aggregation functions can used: sum, min, max, mean, median. conditions option use filtering conditions nodes consider.","code":""},{"path":"/reference/get_agg_degree_in.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"vector aggregate indegree value.","code":""},{"path":"/reference/get_agg_degree_in.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get an aggregate value from the indegree of nodes — get_agg_degree_in","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 20, m = 35, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the mean indegree value # from all nodes in the graph graph %>% get_agg_degree_in( agg = \"mean\") #> [1] 1.75 # Other aggregation functions # can be used (`min`, `max`, # `median`, `sum`); let's get # the median in this example graph %>% get_agg_degree_in( agg = \"median\") #> [1] 1.5 # The aggregation of indegree # can occur for a subset of the # graph nodes and this is made # possible by specifying # `conditions` for the nodes graph %>% get_agg_degree_in( agg = \"mean\", conditions = value > 5.0) #> [1] 1.5"},{"path":"/reference/get_agg_degree_out.html","id":null,"dir":"Reference","previous_headings":"","what":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"Get single, aggregate value outdegree values nodes graph, , subset graph nodes.","code":""},{"path":"/reference/get_agg_degree_out.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"","code":"get_agg_degree_out(graph, agg, conditions = NULL)"},{"path":"/reference/get_agg_degree_out.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"graph graph object class dgr_graph. agg aggregation function use summarizing outdegree values graph nodes. following aggregation functions can used: sum, min, max, mean, median. conditions option use filtering conditions nodes consider.","code":""},{"path":"/reference/get_agg_degree_out.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"vector aggregate outdegree value.","code":""},{"path":"/reference/get_agg_degree_out.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get an aggregate value from the outdegree of nodes — get_agg_degree_out","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 20, m = 35, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the mean outdegree value from all # nodes in the graph graph %>% get_agg_degree_out( agg = \"mean\") #> [1] 1.75 # Other aggregation functions can be used # (`min`, `max`, `median`, `sum`); let's # get the median in this example graph %>% get_agg_degree_out( agg = \"median\") #> [1] 1 # The aggregation of outdegree can occur # for a subset of the graph nodes and this # is made possible by specifying `conditions` # for the nodes graph %>% get_agg_degree_out( agg = \"mean\", conditions = value < 5.0) #> [1] 2.555556"},{"path":"/reference/get_agg_degree_total.html","id":null,"dir":"Reference","previous_headings":"","what":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"Get single, aggregate value total degree values nodes graph, , subset graph nodes.","code":""},{"path":"/reference/get_agg_degree_total.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"","code":"get_agg_degree_total(graph, agg, conditions = NULL)"},{"path":"/reference/get_agg_degree_total.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"graph graph object class dgr_graph. agg aggregation function use summarizing total degree values graph nodes. following aggregation functions can used: sum, min, max, mean, median. conditions option use filtering conditions nodes consider.","code":""},{"path":"/reference/get_agg_degree_total.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"vector aggregate total degree value.","code":""},{"path":"/reference/get_agg_degree_total.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get an aggregate value from the total degree of nodes — get_agg_degree_total","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 20, m = 35, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the mean total degree # value from all nodes in # the graph graph %>% get_agg_degree_total( agg = \"mean\") #> [1] 3.5 # Other aggregation functions # can be used (`min`, `max`, # `median`, `sum`); let's get # the median in this example graph %>% get_agg_degree_total( agg = \"median\") #> [1] 3 # The aggregation of total # degree can occur for a # subset of the graph nodes # and this is made possible # by specifying `conditions` # for the nodes graph %>% get_agg_degree_total( agg = \"mean\", conditions = value < 5.0) #> [1] 4.666667"},{"path":"/reference/get_all_connected_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Get all nodes connected to a specified node — get_all_connected_nodes","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"single node serving starting point get nodes connected (.e., reachable traversable path) node.","code":""},{"path":"/reference/get_all_connected_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"","code":"get_all_connected_nodes(graph, node)"},{"path":"/reference/get_all_connected_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"graph graph object class dgr_graph. node single-length vector containing node ID value.","code":""},{"path":"/reference/get_all_connected_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"vector node ID values.","code":""},{"path":"/reference/get_all_connected_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get all nodes connected to a specified node — get_all_connected_nodes","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function; it # has an unconnected node (`6`) graph_1 <- create_graph() %>% add_gnm_graph( n = 20, m = 32, set_seed = 23) # There won't be any connected # nodes to `6` so when specifying # this node with `get_all_connected_nodes()` # we get NA back graph_1 %>% get_all_connected_nodes( node = 6) #> [1] NA # Any other node in `graph_1` will # provide a vector of all the nodes # other than `6` graph_1 %>% get_all_connected_nodes( node = 1) #> [1] 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 # The following graph has two # clusters of nodes (i.e., the # graph has two connected components) graph_2 <- create_graph() %>% add_path(n = 6) %>% add_path(n = 4) # In `graph_2`, node `1` is in # the larger of the two # connected components graph_2 %>% get_all_connected_nodes( node = 1) #> [1] 2 3 4 5 6 # Also in `graph_2`, node `8` # is in the smaller of the two # connected components graph_2 %>% get_all_connected_nodes( node = 8) #> [1] 7 9 10"},{"path":"/reference/get_alpha_centrality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the alpha centrality for all nodes — get_alpha_centrality","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"Get alpha centrality values nodes graph.","code":""},{"path":"/reference/get_alpha_centrality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"","code":"get_alpha_centrality( graph, alpha = 1, exo = 1, weights_attr = NULL, tol = 1e-07 )"},{"path":"/reference/get_alpha_centrality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"graph graph object class dgr_graph. alpha parameter specifies relative importance endogenous versus exogenous factors determination centrality. exo exogenous factors, cases either constant (applies factor every node), vector giving factor every node. weights_attr optional name edge attribute use adjacency matrix. NULL , exists, weight edge attribute graph used. Failing , standard adjacency matrix used calculations. tol tolerance near-singularities matrix inversion. default value set 1e-7.","code":""},{"path":"/reference/get_alpha_centrality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"data frame alpha centrality scores nodes.","code":""},{"path":"/reference/get_alpha_centrality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the alpha centrality for all nodes — get_alpha_centrality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) # Get the alpha centrality scores # for all nodes graph %>% get_alpha_centrality() #> id alpha_centrality #> 1 1 9 #> 2 2 6 #> 3 3 2 #> 4 4 1 #> 5 5 4 #> 6 6 1 #> 7 7 2 #> 8 8 2 #> 9 9 7 #> 10 10 4 # Add the alpha centrality # scores to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_alpha_centrality(.)) # Display the graph's node # data frame graph %>% get_node_df() #> id type label alpha_centrality #> 1 1 1 9 #> 2 2 2 6 #> 3 3 3 2 #> 4 4 4 1 #> 5 5 5 4 #> 6 6 6 1 #> 7 7 7 2 #> 8 8 8 2 #> 9 9 9 7 #> 10 10 10 4"},{"path":"/reference/get_articulation_points.html","id":null,"dir":"Reference","previous_headings":"","what":"Get articulation points — get_articulation_points","title":"Get articulation points — get_articulation_points","text":"Get nodes graph identified articulation points.","code":""},{"path":"/reference/get_articulation_points.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get articulation points — get_articulation_points","text":"","code":"get_articulation_points(graph)"},{"path":"/reference/get_articulation_points.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get articulation points — get_articulation_points","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_articulation_points.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get articulation points — get_articulation_points","text":"vector node IDs.","code":""},{"path":"/reference/get_articulation_points.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get articulation points — get_articulation_points","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) %>% set_node_attrs( node_attr = shape, values = \"square\") # Get the articulation points # in the graph (i.e., those # nodes that if any were to be # removed, the graph would # become disconnected) graph %>% get_articulation_points() #> [1] 2 4 # For the articulation points, # change the node shape to # a `circle` graph <- graph %>% select_nodes_by_id( nodes = get_articulation_points(.)) %>% set_node_attrs_ws( node_attr = shape, value = \"circle\")"},{"path":"/reference/get_authority_centrality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the authority scores for all nodes — get_authority_centrality","title":"Get the authority scores for all nodes — get_authority_centrality","text":"Get Kleinberg authority centrality scores nodes graph.","code":""},{"path":"/reference/get_authority_centrality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the authority scores for all nodes — get_authority_centrality","text":"","code":"get_authority_centrality(graph, weights_attr = NULL)"},{"path":"/reference/get_authority_centrality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the authority scores for all nodes — get_authority_centrality","text":"graph graph object class dgr_graph. weights_attr optional name edge attribute use adjacency matrix. NULL , exists, weight edge attribute graph used.","code":""},{"path":"/reference/get_authority_centrality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the authority scores for all nodes — get_authority_centrality","text":"data frame authority scores nodes.","code":""},{"path":"/reference/get_authority_centrality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the authority scores for all nodes — get_authority_centrality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the authority centrality scores # for all nodes in the graph graph %>% get_authority_centrality() #> id authority_centrality #> 1 1 6.950912e-01 #> 2 2 6.176471e-01 #> 3 3 0.000000e+00 #> 4 4 1.078669e-16 #> 5 5 3.674279e-01 #> 6 6 3.157923e-01 #> 7 7 4.982552e-01 #> 8 8 1.000000e+00 #> 9 9 1.824629e-01 #> 10 10 6.176471e-01 # Add the authority centrality # scores to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_authority_centrality(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label authority_centrality #> 1 1 1 6.950912e-01 #> 2 2 2 6.176471e-01 #> 3 3 3 0.000000e+00 #> 4 4 4 1.078669e-16 #> 5 5 5 3.674279e-01 #> 6 6 6 3.157923e-01 #> 7 7 7 4.982552e-01 #> 8 8 8 1.000000e+00 #> 9 9 9 1.824629e-01 #> 10 10 10 6.176471e-01"},{"path":"/reference/get_betweenness.html","id":null,"dir":"Reference","previous_headings":"","what":"Get betweenness centrality scores — get_betweenness","title":"Get betweenness centrality scores — get_betweenness","text":"Get betweenness centrality scores nodes graph.","code":""},{"path":"/reference/get_betweenness.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get betweenness centrality scores — get_betweenness","text":"","code":"get_betweenness(graph)"},{"path":"/reference/get_betweenness.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get betweenness centrality scores — get_betweenness","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_betweenness.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get betweenness centrality scores — get_betweenness","text":"data frame betweenness scores nodes.","code":""},{"path":"/reference/get_betweenness.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get betweenness centrality scores — get_betweenness","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) # Get the betweenness scores # for nodes in the graph graph %>% get_betweenness() #> id betweenness #> 1 1 0 #> 2 2 7 #> 3 3 0 #> 4 4 0 #> 5 5 5 #> 6 6 0 #> 7 7 0 #> 8 8 1 #> 9 9 0 #> 10 10 0 # Add the betweenness # values to the graph # as a node attribute graph <- graph %>% join_node_attrs( df = get_betweenness(.)) # Display the graph's node # data frame graph %>% get_node_df() #> id type label betweenness #> 1 1 1 0 #> 2 2 2 7 #> 3 3 3 0 #> 4 4 4 0 #> 5 5 5 5 #> 6 6 6 0 #> 7 7 7 0 #> 8 8 8 1 #> 9 9 9 0 #> 10 10 10 0"},{"path":"/reference/get_cache.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a cached vector from a graph object — get_cache","title":"Get a cached vector from a graph object — get_cache","text":"Get vector cached graph object class dgr_graph.","code":""},{"path":"/reference/get_cache.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a cached vector from a graph object — get_cache","text":"","code":"get_cache(graph, name = NULL)"},{"path":"/reference/get_cache.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a cached vector from a graph object — get_cache","text":"graph graph object class dgr_graph. name name object extract cache. none supplied, recent object added cache returned.","code":""},{"path":"/reference/get_cache.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a cached vector from a graph object — get_cache","text":"vector.","code":""},{"path":"/reference/get_cache.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a cached vector from a graph object — get_cache","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a graph with 5 nodes and 5 edges graph <- create_graph() %>% add_n_nodes(n = 5) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 8, sd = 2)) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->2\") # Cache all values from the node attribute `value` # as a numeric vector graph <- graph %>% set_cache( name = \"value\", to_cache = get_node_attrs( graph = ., node_attr = value)) # Return the cached vector graph %>% get_cache() #> 1 2 3 4 5 #> 9.993210 10.214981 7.443827 10.038411 8.090874"},{"path":"/reference/get_closeness.html","id":null,"dir":"Reference","previous_headings":"","what":"Get closeness centrality values — get_closeness","title":"Get closeness centrality values — get_closeness","text":"Get closeness centrality values nodes graph.","code":""},{"path":"/reference/get_closeness.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get closeness centrality values — get_closeness","text":"","code":"get_closeness(graph, direction = \"all\")"},{"path":"/reference/get_closeness.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get closeness centrality values — get_closeness","text":"graph graph object class dgr_graph. direction using (default), search ignore edge direction traversing graph. , measurements paths node whereas , measurements paths node.","code":""},{"path":"/reference/get_closeness.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get closeness centrality values — get_closeness","text":"data frame closeness values nodes.","code":""},{"path":"/reference/get_closeness.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get closeness centrality values — get_closeness","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) # Get closeness values for all nodes # in the graph graph %>% get_closeness() #> id closeness #> 1 1 0.05263158 #> 2 2 0.06250000 #> 3 3 0.05555556 #> 4 4 0.06666667 #> 5 5 0.06666667 #> 6 6 0.04166667 #> 7 7 0.04347826 #> 8 8 0.05555556 #> 9 9 0.04166667 #> 10 10 0.04545455 # Add the closeness values to # the graph as a node attribute graph <- graph %>% join_node_attrs( df = get_closeness(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label closeness #> 1 1 1 0.05263158 #> 2 2 2 0.06250000 #> 3 3 3 0.05555556 #> 4 4 4 0.06666667 #> 5 5 5 0.06666667 #> 6 6 6 0.04166667 #> 7 7 7 0.04347826 #> 8 8 8 0.05555556 #> 9 9 9 0.04166667 #> 10 10 10 0.04545455"},{"path":"/reference/get_closeness_vitality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get closeness vitality — get_closeness_vitality","title":"Get closeness vitality — get_closeness_vitality","text":"Get closeness vitality values nodes graph.","code":""},{"path":"/reference/get_closeness_vitality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get closeness vitality — get_closeness_vitality","text":"","code":"get_closeness_vitality(graph)"},{"path":"/reference/get_closeness_vitality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get closeness vitality — get_closeness_vitality","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_closeness_vitality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get closeness vitality — get_closeness_vitality","text":"data frame closeness vitality values nodes.","code":""},{"path":"/reference/get_closeness_vitality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get closeness vitality — get_closeness_vitality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 12, set_seed = 23) # Get closeness vitality values # for all nodes in the graph graph %>% get_closeness_vitality() #> id closeness_vitality #> 1 1 32 #> 2 2 118 #> 3 3 36 #> 4 4 60 #> 5 5 0 #> 6 6 48 #> 7 7 46 #> 8 8 30 #> 9 9 48 #> 10 10 44 # Add the closeness vitality # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_closeness_vitality(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label closeness_vitality #> 1 1 1 32 #> 2 2 2 118 #> 3 3 3 36 #> 4 4 4 60 #> 5 5 5 0 #> 6 6 6 48 #> 7 7 7 46 #> 8 8 8 30 #> 9 9 9 48 #> 10 10 10 44"},{"path":"/reference/get_cmty_edge_btwns.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership by edge betweenness — get_cmty_edge_btwns","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"Using edge betweenness, obtain group membership values nodes graph.","code":""},{"path":"/reference/get_cmty_edge_btwns.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"","code":"get_cmty_edge_btwns(graph)"},{"path":"/reference/get_cmty_edge_btwns.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_cmty_edge_btwns.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_edge_btwns.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership by edge betweenness — get_cmty_edge_btwns","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the group membership # values for all nodes in the # graph through calculation of # the leading non-negative # eigenvector of the modularity # matrix of the graph graph %>% get_cmty_edge_btwns() #> id edge_btwns_group #> 1 1 1 #> 2 2 2 #> 3 3 2 #> 4 4 3 #> 5 5 2 #> 6 6 2 #> 7 7 1 #> 8 8 3 #> 9 9 3 #> 10 10 4 # Add the group membership # values to the graph # as a node attribute graph <- graph %>% join_node_attrs( df = get_cmty_edge_btwns(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label edge_btwns_group #> 1 1 1 1 #> 2 2 2 2 #> 3 3 3 2 #> 4 4 4 3 #> 5 5 5 2 #> 6 6 6 2 #> 7 7 7 1 #> 8 8 8 3 #> 9 9 9 3 #> 10 10 10 4"},{"path":"/reference/get_cmty_fast_greedy.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership by modularity optimization — get_cmty_fast_greedy","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"use greedy optimization modularity score, obtain group membership values nodes graph. Note method works graphs without multiple edges.","code":""},{"path":"/reference/get_cmty_fast_greedy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"","code":"get_cmty_fast_greedy(graph)"},{"path":"/reference/get_cmty_fast_greedy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_cmty_fast_greedy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_fast_greedy.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership by modularity optimization — get_cmty_fast_greedy","text":"","code":"# Create a graph with a # balanced tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Get the group membership # values for all nodes in # the graph through the greedy # optimization of modularity # algorithm graph %>% get_cmty_fast_greedy() #> id f_g_group #> 1 1 1 #> 2 2 2 #> 3 3 1 #> 4 4 2 #> 5 5 2 #> 6 6 1 #> 7 7 1 # Add the group membership # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_cmty_fast_greedy(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label f_g_group #> 1 1 1 1 #> 2 2 2 2 #> 3 3 3 1 #> 4 4 4 2 #> 5 5 5 2 #> 6 6 6 1 #> 7 7 7 1"},{"path":"/reference/get_cmty_l_eigenvec.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"calculation leading non-negative eigenvector modularity matrix graph, obtain group membership values nodes graph.","code":""},{"path":"/reference/get_cmty_l_eigenvec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"","code":"get_cmty_l_eigenvec(graph)"},{"path":"/reference/get_cmty_l_eigenvec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_cmty_l_eigenvec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_l_eigenvec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership by leading eigenvector — get_cmty_l_eigenvec","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the group membership # values for all nodes in the # graph through calculation of # the leading non-negative # eigenvector of the modularity # matrix of the graph graph %>% get_cmty_l_eigenvec() #> id l_eigenvec_group #> 1 1 1 #> 2 2 3 #> 3 3 3 #> 4 4 1 #> 5 5 3 #> 6 6 3 #> 7 7 1 #> 8 8 1 #> 9 9 1 #> 10 10 2 # Add the group membership # values to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_cmty_l_eigenvec(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label l_eigenvec_group #> 1 1 1 1 #> 2 2 2 3 #> 3 3 3 3 #> 4 4 4 1 #> 5 5 5 3 #> 6 6 6 3 #> 7 7 7 1 #> 8 8 8 1 #> 9 9 9 1 #> 10 10 10 2"},{"path":"/reference/get_cmty_louvain.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership by Louvain optimization — get_cmty_louvain","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"use multi-level optimization modularity score, obtain group membership values nodes graph.","code":""},{"path":"/reference/get_cmty_louvain.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"","code":"get_cmty_louvain(graph)"},{"path":"/reference/get_cmty_louvain.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_cmty_louvain.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_louvain.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership by Louvain optimization — get_cmty_louvain","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the group membership values # for all nodes in the graph # through the multi-level # optimization of modularity # algorithm graph %>% get_cmty_louvain() #> id louvain_group #> 1 1 1 #> 2 2 2 #> 3 3 2 #> 4 4 3 #> 5 5 2 #> 6 6 2 #> 7 7 1 #> 8 8 3 #> 9 9 3 #> 10 10 4 # Add the group membership # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_cmty_louvain(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label louvain_group #> 1 1 1 1 #> 2 2 2 2 #> 3 3 3 2 #> 4 4 4 3 #> 5 5 5 2 #> 6 6 6 2 #> 7 7 7 1 #> 8 8 8 3 #> 9 9 9 3 #> 10 10 10 4"},{"path":"/reference/get_cmty_walktrap.html","id":null,"dir":"Reference","previous_headings":"","what":"Get community membership using the Walktrap method — get_cmty_walktrap","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"Walktrap community finding algorithm, obtain group membership values nodes graph.","code":""},{"path":"/reference/get_cmty_walktrap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"","code":"get_cmty_walktrap(graph, steps = 4)"},{"path":"/reference/get_cmty_walktrap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"graph graph object class dgr_graph. steps number steps take random walks.","code":""},{"path":"/reference/get_cmty_walktrap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"data frame group membership assignments nodes.","code":""},{"path":"/reference/get_cmty_walktrap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get community membership using the Walktrap method — get_cmty_walktrap","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the group membership # values for all nodes in the # graph through the Walktrap # community finding algorithm graph %>% get_cmty_walktrap() #> id walktrap_group #> 1 1 3 #> 2 2 2 #> 3 3 2 #> 4 4 1 #> 5 5 2 #> 6 6 2 #> 7 7 3 #> 8 8 1 #> 9 9 1 #> 10 10 4 # Add the group membership # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_cmty_walktrap(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label walktrap_group #> 1 1 1 3 #> 2 2 2 2 #> 3 3 3 2 #> 4 4 4 1 #> 5 5 5 2 #> 6 6 6 2 #> 7 7 7 3 #> 8 8 8 1 #> 9 9 9 1 #> 10 10 10 4"},{"path":"/reference/get_common_nbrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get all common neighbors between two or more nodes — get_common_nbrs","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"two nodes, get set common neighboring nodes.","code":""},{"path":"/reference/get_common_nbrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"","code":"get_common_nbrs(graph, nodes)"},{"path":"/reference/get_common_nbrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"graph graph object class dgr_graph. nodes vector node ID values length least 2.","code":""},{"path":"/reference/get_common_nbrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"vector node ID values.","code":""},{"path":"/reference/get_common_nbrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get all common neighbors between two or more nodes — get_common_nbrs","text":"","code":"# Create a directed graph with 5 nodes graph <- create_graph() %>% add_path(n = 5) # Find all common neighbor nodes # for nodes `1` and `2` (there are no # common neighbors amongst them) graph %>% get_common_nbrs( nodes = c(1, 2)) #> [1] NA # Find all common neighbor nodes for # nodes `1` and `3` graph %>% get_common_nbrs( nodes = c(1, 3)) #> [1] 2"},{"path":"/reference/get_coreness.html","id":null,"dir":"Reference","previous_headings":"","what":"Get coreness values for graph nodes — get_coreness","title":"Get coreness values for graph nodes — get_coreness","text":"Get coreness values nodes graph.","code":""},{"path":"/reference/get_coreness.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get coreness values for graph nodes — get_coreness","text":"","code":"get_coreness(graph, direction = \"all\")"},{"path":"/reference/get_coreness.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get coreness values for graph nodes — get_coreness","text":"graph graph object class dgr_graph. direction using (default), search ignore edge direction traversing graph. , measurements paths node whereas , measurements paths node.","code":""},{"path":"/reference/get_coreness.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get coreness values for graph nodes — get_coreness","text":"data frame coreness values nodes.","code":""},{"path":"/reference/get_coreness.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get coreness values for graph nodes — get_coreness","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get coreness values for # all nodes in the graph graph %>% get_coreness() #> id coreness #> 1 1 3 #> 2 2 3 #> 3 3 2 #> 4 4 3 #> 5 5 3 #> 6 6 3 #> 7 7 3 #> 8 8 2 #> 9 9 2 #> 10 10 0 # Add the coreness values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_coreness(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label coreness #> 1 1 1 3 #> 2 2 2 3 #> 3 3 3 2 #> 4 4 4 3 #> 5 5 5 3 #> 6 6 6 3 #> 7 7 7 3 #> 8 8 8 2 #> 9 9 9 2 #> 10 10 10 0"},{"path":"/reference/get_degree_distribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Get total degree distribution data for a graph — get_degree_distribution","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"Get degree distribution data graph. Graph degree represented frequency total degree values nodes graph.","code":""},{"path":"/reference/get_degree_distribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"","code":"get_degree_distribution(graph, mode = \"total\")"},{"path":"/reference/get_degree_distribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"graph graph object class dgr_graph. mode using total (default), degree considered node total degree. degree used -degree -degree, respectively.","code":""},{"path":"/reference/get_degree_distribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"data frame degree frequencies.","code":""},{"path":"/reference/get_degree_distribution.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get total degree distribution data for a graph — get_degree_distribution","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the total degree # distribution for the graph graph %>% get_degree_distribution( mode = \"total\") #> degree total_degree_dist #> 1 0 0.1 #> 2 1 0.0 #> 3 2 0.2 #> 4 3 0.4 #> 5 4 0.1 #> 6 5 0.2"},{"path":"/reference/get_degree_histogram.html","id":null,"dir":"Reference","previous_headings":"","what":"Get histogram data for a graph's degree frequency — get_degree_histogram","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"Get histogram data graph's degree frequency. bin width set 1 zero-value degrees omitted output.","code":""},{"path":"/reference/get_degree_histogram.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"","code":"get_degree_histogram(graph, mode = \"total\")"},{"path":"/reference/get_degree_histogram.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"graph graph object class dgr_graph. mode using total (default), degree considered node total degree. degree used -degree -degree, respectively.","code":""},{"path":"/reference/get_degree_histogram.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"data frame degree counts.","code":""},{"path":"/reference/get_degree_histogram.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get histogram data for a graph's degree frequency — get_degree_histogram","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get degree histogram data for # the graph (reporting total degree) graph %>% get_degree_histogram( mode = \"total\") #> degree total_degree_hist #> 1 0 1 #> 2 1 0 #> 3 2 2 #> 4 3 4 #> 5 4 1 #> 6 5 2"},{"path":"/reference/get_degree_in.html","id":null,"dir":"Reference","previous_headings":"","what":"Get indegree values for all nodes — get_degree_in","title":"Get indegree values for all nodes — get_degree_in","text":"Get indegree values nodes graph.","code":""},{"path":"/reference/get_degree_in.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get indegree values for all nodes — get_degree_in","text":"","code":"get_degree_in(graph, normalized = FALSE)"},{"path":"/reference/get_degree_in.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get indegree values for all nodes — get_degree_in","text":"graph graph object class dgr_graph. normalized set FALSE (default), indegree provided nodes (count edges node). set TRUE, result node divided total number nodes graph minus 1.","code":""},{"path":"/reference/get_degree_in.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get indegree values for all nodes — get_degree_in","text":"data frame indegree values nodes.","code":""},{"path":"/reference/get_degree_in.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get indegree values for all nodes — get_degree_in","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the indegree values for # all nodes in the graph graph %>% get_degree_in() #> id indegree #> 1 1 3 #> 2 2 3 #> 3 3 2 #> 4 4 5 #> 5 5 4 #> 6 6 5 #> 7 7 3 #> 8 8 2 #> 9 9 3 #> 10 10 0 # Add the indegree values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_degree_in(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label indegree #> 1 1 1 3 #> 2 2 2 3 #> 3 3 3 2 #> 4 4 4 5 #> 5 5 5 4 #> 6 6 6 5 #> 7 7 7 3 #> 8 8 8 2 #> 9 9 9 3 #> 10 10 10 0"},{"path":"/reference/get_degree_out.html","id":null,"dir":"Reference","previous_headings":"","what":"Get outdegree values for all nodes — get_degree_out","title":"Get outdegree values for all nodes — get_degree_out","text":"Get outdegree values nodes graph.","code":""},{"path":"/reference/get_degree_out.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get outdegree values for all nodes — get_degree_out","text":"","code":"get_degree_out(graph, normalized = FALSE)"},{"path":"/reference/get_degree_out.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get outdegree values for all nodes — get_degree_out","text":"graph graph object class dgr_graph. normalized set FALSE (default), outdegree provided nodes (count edges outgoing node). set TRUE, result node divided total number nodes graph minus 1.","code":""},{"path":"/reference/get_degree_out.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get outdegree values for all nodes — get_degree_out","text":"data frame outdegree values nodes.","code":""},{"path":"/reference/get_degree_out.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get outdegree values for all nodes — get_degree_out","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the outdegree values # for all nodes in the graph graph %>% get_degree_out() #> id outdegree #> 1 1 3 #> 2 2 3 #> 3 3 2 #> 4 4 5 #> 5 5 4 #> 6 6 5 #> 7 7 3 #> 8 8 2 #> 9 9 3 #> 10 10 0 # Add the outdegree values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_degree_out(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label outdegree #> 1 1 1 3 #> 2 2 2 3 #> 3 3 3 2 #> 4 4 4 5 #> 5 5 5 4 #> 6 6 6 5 #> 7 7 7 3 #> 8 8 8 2 #> 9 9 9 3 #> 10 10 10 0"},{"path":"/reference/get_degree_total.html","id":null,"dir":"Reference","previous_headings":"","what":"Get total degree values for all nodes — get_degree_total","title":"Get total degree values for all nodes — get_degree_total","text":"Get total degree values nodes graph.","code":""},{"path":"/reference/get_degree_total.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get total degree values for all nodes — get_degree_total","text":"","code":"get_degree_total(graph, normalized = FALSE)"},{"path":"/reference/get_degree_total.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get total degree values for all nodes — get_degree_total","text":"graph graph object class dgr_graph. normalized set FALSE (default), total degree provided nodes (count edges node). set TRUE, result node divided total number nodes graph minus 1.","code":""},{"path":"/reference/get_degree_total.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get total degree values for all nodes — get_degree_total","text":"data frame total degree values nodes.","code":""},{"path":"/reference/get_degree_total.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get total degree values for all nodes — get_degree_total","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the total degree values # for all nodes in the graph graph %>% get_degree_total() #> id total_degree #> 1 1 3 #> 2 2 3 #> 3 3 2 #> 4 4 5 #> 5 5 4 #> 6 6 5 #> 7 7 3 #> 8 8 2 #> 9 9 3 #> 10 10 0 # Add the total degree values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_degree_total(.)) # Display the graph's # node data frame graph %>% get_node_df() #> id type label total_degree #> 1 1 1 3 #> 2 2 2 3 #> 3 3 3 2 #> 4 4 4 5 #> 5 5 5 4 #> 6 6 6 5 #> 7 7 7 3 #> 8 8 8 2 #> 9 9 9 3 #> 10 10 10 0"},{"path":"/reference/get_dice_similarity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Dice similarity coefficient scores — get_dice_similarity","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"Get Dice similarity coefficient scores one nodes graph.","code":""},{"path":"/reference/get_dice_similarity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"","code":"get_dice_similarity(graph, nodes = NULL, direction = \"all\", round_to = 3)"},{"path":"/reference/get_dice_similarity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"graph graph object class dgr_graph. nodes optional vector node IDs consider Dice similarity scores. supplied, similarity scores provided every pair nodes graph. direction using (default), function ignore edge direction determining scores neighboring nodes. , edge direction neighboring nodes considered. round_to maximum number decimal places retain Dice similarity coefficient scores. default value 3.","code":""},{"path":"/reference/get_dice_similarity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"matrix Dice similarity values pair nodes considered.","code":""},{"path":"/reference/get_dice_similarity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get Dice similarity coefficient scores — get_dice_similarity","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the Dice similarity # values for nodes `5`, `6`, # and `7` graph %>% get_dice_similarity( nodes = 5:7) #> 5 6 7 #> 5 1.000 0.444 0.571 #> 6 0.444 1.000 0.500 #> 7 0.571 0.500 1.000"},{"path":"/reference/get_eccentricity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node eccentricities — get_eccentricity","title":"Get node eccentricities — get_eccentricity","text":"Get data frame node eccentricity values.","code":""},{"path":"/reference/get_eccentricity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node eccentricities — get_eccentricity","text":"","code":"get_eccentricity(graph, mode = \"out\")"},{"path":"/reference/get_eccentricity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node eccentricities — get_eccentricity","text":"graph graph object class dgr_graph. mode mode shortest paths given vertices calculated directed graphs. (default) shortest paths node, shortest paths node considered. used, corresponding undirected graph used edge directions ignored. undirected graphs, argument ignored.","code":""},{"path":"/reference/get_eccentricity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node eccentricities — get_eccentricity","text":"data frame containing eccentricity values node ID value.","code":""},{"path":"/reference/get_eccentricity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node eccentricities — get_eccentricity","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the eccentricity values for # all nodes in the graph graph %>% get_eccentricity() #> id eccentricity #> 1 1 2 #> 2 2 3 #> 3 3 3 #> 4 4 2 #> 5 5 3 #> 6 6 2 #> 7 7 3 #> 8 8 3 #> 9 9 2 #> 10 10 0"},{"path":"/reference/get_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get edge attribute values — get_edge_attrs","title":"Get edge attribute values — get_edge_attrs","text":"graph object class dgr_graph, get edge attribute values one edges.","code":""},{"path":"/reference/get_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get edge attribute values — get_edge_attrs","text":"","code":"get_edge_attrs(graph, edge_attr, from = NULL, to = NULL)"},{"path":"/reference/get_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get edge attribute values — get_edge_attrs","text":"graph graph object class dgr_graph. edge_attr name attribute get values. optional vector node IDs edge outgoing filtering list edges. optional vector node IDs edge incoming filtering list edges.","code":""},{"path":"/reference/get_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get edge attribute values — get_edge_attrs","text":"named vector edge attribute values attribute given edge_attr edge.","code":""},{"path":"/reference/get_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get edge attribute values — get_edge_attrs","text":"","code":"# Create a simple graph where # edges have an edge attribute # named `value` graph <- create_graph() %>% add_n_nodes(n = 4) %>% { edges <- create_edge_df( from = c(1, 2, 1, 4), to = c(2, 3, 4, 3), rel = \"rel\") add_edge_df( graph = ., edge_df = edges) } %>% set_edge_attrs( edge_attr = value, values = 1.6, from = 1, to = 2) %>% set_edge_attrs( edge_attr = value, values = 4.3, from = 1, to = 4) %>% set_edge_attrs( edge_attr = value, values = 2.9, from = 2, to = 3) %>% set_edge_attrs( edge_attr = value, values = 8.4, from = 4, to = 3) # Get the values for the # `value` edge attribute graph %>% get_edge_attrs( edge_attr = value) #> 1->2 2->3 1->4 4->3 #> 1.6 2.9 4.3 8.4 # To only return edge attribute # values for specified edges, use # the `from` and `to` arguments graph %>% get_edge_attrs( edge_attr = value, from = c(1, 2), to = c(2, 3)) #> 1->2 2->3 #> 1.6 2.9"},{"path":"/reference/get_edge_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"graph object class dgr_graph, get edge attribute values one edges. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/get_edge_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"","code":"get_edge_attrs_ws(graph, edge_attr)"},{"path":"/reference/get_edge_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"graph graph object class dgr_graph. edge_attr name attribute get values.","code":""},{"path":"/reference/get_edge_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"named vector edge attribute values attribute given edge_attr edge.","code":""},{"path":"/reference/get_edge_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get edge attribute values from a selection of edges — get_edge_attrs_ws","text":"","code":"# Create a simple graph where # edges have an edge attribute # named `value` graph <- create_graph() %>% add_n_nodes(n = 4) %>% { edges <- create_edge_df( from = c(1, 2, 1, 4), to = c(2, 3, 4, 3), rel = \"rel\") add_edge_df( graph = ., edge_df = edges) } %>% set_edge_attrs( edge_attr = value, values = 1.6, from = 1, to = 2) %>% set_edge_attrs( edge_attr = value, values = 4.3, from = 1, to = 4) %>% set_edge_attrs( edge_attr = value, values = 2.9, from = 2, to = 3) %>% set_edge_attrs( edge_attr = value, values = 8.4, from = 4, to = 3) # Select the edges defined as # `1`->`3` and `2`->`3` graph <- graph %>% select_edges( from = c(1, 2), to = c(2, 3)) # Get the edge attribute values # for the `value` attribute, limited # to the current edge selection graph %>% get_edge_attrs_ws( edge_attr = value) #> 1->2 2->3 #> 1.6 2.9"},{"path":"/reference/get_edge_count_w_multiedge.html","id":null,"dir":"Reference","previous_headings":"","what":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"Get count number edge definitions (e.g, 1 -> 2) multiple edges (.e., 1 edge definition, distinct edge ID values). , example, 2 edge definitions graph involve 6 separate edge IDs (3 edge IDs pairs nodes), count 2.","code":""},{"path":"/reference/get_edge_count_w_multiedge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"","code":"get_edge_count_w_multiedge(graph)"},{"path":"/reference/get_edge_count_w_multiedge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_edge_count_w_multiedge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"vector single, numerical value.","code":""},{"path":"/reference/get_edge_count_w_multiedge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get count of edge definitions where multiple edges occur — get_edge_count_w_multiedge","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 5, label = TRUE) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 4, 4, 3, 5, 1, 3, 4), to = c(4, 1, 1, 2, 2, 2, 2, 1)) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get the total number of edge # definitions (e.g., `4` -> `1`) where # there are multiple edges (i.e., # distinct edges with separate edge # ID values) graph %>% get_edge_count_w_multiedge() #> [1] 2"},{"path":"/reference/get_edge_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Get an edge data frame from a graph — get_edge_df","title":"Get an edge data frame from a graph — get_edge_df","text":"graph, obtain edge data frame current edge attributes.","code":""},{"path":"/reference/get_edge_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get an edge data frame from a graph — get_edge_df","text":"","code":"get_edge_df(graph)"},{"path":"/reference/get_edge_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get an edge data frame from a graph — get_edge_df","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_edge_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get an edge data frame from a graph — get_edge_df","text":"edge data frame.","code":""},{"path":"/reference/get_edge_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get an edge data frame from a graph — get_edge_df","text":"","code":"# Create a graph graph <- create_graph() %>% add_n_nodes( n = 1, type = \"a\") %>% select_last_nodes_created() %>% add_n_nodes_ws( n = 5, direction = \"from\", type = \"b\") %>% select_edges_by_node_id( nodes = 3:5) %>% set_edge_attrs_ws( edge_attr = color, value = \"green\") %>% set_edge_attrs_ws( edge_attr = rel, value = \"a\") %>% invert_selection %>% set_edge_attrs_ws( edge_attr = color, value = \"blue\") %>% set_edge_attrs_ws( edge_attr = rel, value = \"b\") %>% clear_selection() # Get the graph's internal # edge data frame (edf) graph %>% get_edge_df() #> id from to rel color #> 1 1 1 2 b blue #> 2 2 1 3 a green #> 3 3 1 4 a green #> 4 4 1 5 a green #> 5 5 1 6 b blue"},{"path":"/reference/get_edge_df_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"graph object class dgr_graph, get graph's internal edge data frame filtered edge ID values currently active selection. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/get_edge_df_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"","code":"get_edge_df_ws(graph)"},{"path":"/reference/get_edge_df_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_edge_df_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"edge data frame.","code":""},{"path":"/reference/get_edge_df_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph's edf filtered by a selection of edges — get_edge_df_ws","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_edge_attrs( edge_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # Select edges with ID values # `1` and `3` graph <- graph %>% select_edges_by_edge_id( edges = c(1, 3)) # Get the edge data frame that's # limited to the rows that correspond # to the edge selection graph %>% get_edge_df_ws() #> id from to rel value #> 1 1 2 1 2.5 #> 2 3 3 2 4.2"},{"path":"/reference/get_edge_ids.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a vector of edge ID values — get_edge_ids","title":"Get a vector of edge ID values — get_edge_ids","text":"Obtain vector edge ID values graph object. optional filter edge attribute can limit set edge ID values returned.","code":""},{"path":"/reference/get_edge_ids.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a vector of edge ID values — get_edge_ids","text":"","code":"get_edge_ids(graph, conditions = NULL)"},{"path":"/reference/get_edge_ids.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a vector of edge ID values — get_edge_ids","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval edges.","code":""},{"path":"/reference/get_edge_ids.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a vector of edge ID values — get_edge_ids","text":"vector edge ID values.","code":""},{"path":"/reference/get_edge_ids.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a vector of edge ID values — get_edge_ids","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"letter\", color = c(\"red\", \"green\", \"grey\", \"blue\"), value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\", color = c(\"pink\", \"blue\", \"blue\"), value = c(3.9, 2.5, 7.3)) # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get a vector of all edges in a graph graph %>% get_edge_ids() #> [1] 1 2 3 # Get a vector of edge ID values using a # numeric comparison (i.e., all edges with # `value` attribute greater than 3) get_edge_ids( graph, conditions = value > 3) #> [1] 1 3 # Get a vector of edge ID values using # a match pattern (i.e., all edges with # `color` attribute of `pink`) get_edge_ids( graph, conditions = color == \"pink\") #> [1] 1 # Use multiple conditions to return edges # with the desired attribute values get_edge_ids( graph, conditions = color == \"blue\" & value > 5) #> [1] 3"},{"path":"/reference/get_edge_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get detailed information on edges — get_edge_info","title":"Get detailed information on edges — get_edge_info","text":"Obtain data frame detailed information edges interrelationships within graph.","code":""},{"path":"/reference/get_edge_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get detailed information on edges — get_edge_info","text":"","code":"get_edge_info(graph)"},{"path":"/reference/get_edge_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get detailed information on edges — get_edge_info","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_edge_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get detailed information on edges — get_edge_info","text":"data frame containing information specific edge within graph.","code":""},{"path":"/reference/get_edge_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get detailed information on edges — get_edge_info","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) # Get information on the # graph's edges graph %>% get_edge_info() #> id from to rel #> 1 1 1 3 #> 2 2 2 1 #> 3 3 2 5 #> 4 4 2 3 #> 5 5 3 1 #> 6 6 3 2 #> 7 7 3 5 #> 8 8 3 4 #> 9 9 4 1 #> 10 10 5 4 "},{"path":"/reference/get_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node IDs associated with edges — get_edges","title":"Get node IDs associated with edges — get_edges","text":"Obtain vector, data frame, list node IDs associated edges graph object. optional filter edge attribute can limit set edges returned.","code":""},{"path":"/reference/get_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node IDs associated with edges — get_edges","text":"","code":"get_edges( graph, conditions = NULL, return_type = \"vector\", return_values = \"id\" )"},{"path":"/reference/get_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node IDs associated with edges — get_edges","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval edges. return_type using vector (default), vector character objects representing edges provided. list list object provided contains vectors outgoing incoming node IDs associated edges. df, data frame containing outgoing incoming node IDs associated edges. return_values using id (default) results node ID values returned edge definitions. label, node labels instead used define edges.","code":""},{"path":"/reference/get_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node IDs associated with edges — get_edges","text":"list, data frame, vector object, depending value given return_type.","code":""},{"path":"/reference/get_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node IDs associated with edges — get_edges","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, label = c(\"one\", \"two\", \"three\", \"four\"), type = \"letter\", color = c(\"red\", \"green\", \"grey\", \"blue\"), value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\", color = c(\"pink\", \"blue\", \"blue\"), value = c(3.9, 2.5, 7.3)) # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get all edges within a graph, returned as a list graph %>% get_edges( return_type = \"vector\") #> [1] \"1->4\" \"2->3\" \"3->1\" # Get all edges within a graph, returned as a # data frame graph %>% get_edges( return_type = \"df\") #> from to #> 1 1 4 #> 2 2 3 #> 3 3 1 # Get all edges returned as a list graph %>% get_edges( return_type = \"list\") #> [[1]] #> [1] 1 2 3 #> #> [[2]] #> [1] 4 3 1 #> # Get a vector of edges using # a numeric comparison (i.e., # all edges with a `value` # attribute greater than 3) graph %>% get_edges( conditions = value > 3, return_type = \"vector\") #> [1] \"1->4\" \"3->1\" # Get a vector of edges using # a matching condition graph %>% get_edges( conditions = color == \"pink\", return_type = \"vector\") #> [1] \"1->4\" # Use multiple conditions to # return edges with the # desired attribute values graph %>% get_edges( conditions = color == \"blue\" & value > 3, return_type = \"vector\") #> [1] \"3->1\" # Use `return_values = \"label\"` # to return the labels of the # connected nodes graph %>% get_edges( conditions = color == \"blue\" & value > 3, return_type = \"vector\", return_values = \"label\") #> [1] \"three->one\""},{"path":"/reference/get_eigen_centrality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the eigen centrality for all nodes — get_eigen_centrality","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"Get eigen centrality values nodes graph.","code":""},{"path":"/reference/get_eigen_centrality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"","code":"get_eigen_centrality(graph, weights_attr = NULL)"},{"path":"/reference/get_eigen_centrality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"graph graph object class dgr_graph. weights_attr optional name edge attribute use adjacency matrix. NULL , exists, weight edge attribute graph used. NA edge weights used.","code":""},{"path":"/reference/get_eigen_centrality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"data frame eigen centrality scores nodes.","code":""},{"path":"/reference/get_eigen_centrality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the eigen centrality for all nodes — get_eigen_centrality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the eigen centrality scores # for nodes in the graph graph %>% get_eigen_centrality() #> id eigen_centrality #> 1 1 0.6640 #> 2 2 0.6767 #> 3 3 0.4988 #> 4 4 0.9541 #> 5 5 0.7908 #> 6 6 1.0000 #> 7 7 0.6391 #> 8 8 0.4524 #> 9 9 0.6702 #> 10 10 0.0000"},{"path":"/reference/get_girth.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph girth — get_girth","title":"Get the graph girth — get_girth","text":"Get girth graph, length shortest circle graph. Loop edges multiple edges considered. graph contains cycles zero returned.","code":""},{"path":"/reference/get_girth.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph girth — get_girth","text":"","code":"get_girth(graph)"},{"path":"/reference/get_girth.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph girth — get_girth","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_girth.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph girth — get_girth","text":"single numeric value representing length shortest circle graph.","code":""},{"path":"/reference/get_girth.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph girth — get_girth","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the graph's girth graph %>% get_girth() #> [1] 5 # Create a full graph and then # get the girth for that create_graph() %>% add_full_graph(n = 10) %>% get_girth() #> [1] 3"},{"path":"/reference/get_global_graph_attr_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get global graph attributes — get_global_graph_attr_info","title":"Get global graph attributes — get_global_graph_attr_info","text":"Get available global attributes graph object class dgr_graph.","code":""},{"path":"/reference/get_global_graph_attr_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get global graph attributes — get_global_graph_attr_info","text":"","code":"get_global_graph_attr_info(graph)"},{"path":"/reference/get_global_graph_attr_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get global graph attributes — get_global_graph_attr_info","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_global_graph_attr_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get global graph attributes — get_global_graph_attr_info","text":"data frame containing global attributes graph.","code":""},{"path":"/reference/get_global_graph_attr_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get global graph attributes — get_global_graph_attr_info","text":"","code":"# Create a new, empty graph graph <- create_graph() # View the graph's set of # global attributes graph %>% get_global_graph_attr_info() #> # A tibble: 17 × 3 #> attr value attr_type #> #> 1 layout neato graph #> 2 outputorder edgesfirst graph #> 3 bgcolor white graph #> 4 fontname Helvetica node #> 5 fontsize 10 node #> 6 shape circle node #> 7 fixedsize true node #> 8 width 0.5 node #> 9 style filled node #> 10 fillcolor aliceblue node #> 11 color gray70 node #> 12 fontcolor gray50 node #> 13 fontname Helvetica edge #> 14 fontsize 8 edge #> 15 len 1.5 edge #> 16 color gray80 edge #> 17 arrowsize 0.5 edge"},{"path":"/reference/get_graph_actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Get information on any available graph actions — get_graph_actions","title":"Get information on any available graph actions — get_graph_actions","text":"Get tibble available graph actions, contains information function invocations called graph every transformation step, , manually invoked trigger_graph_actions() function.","code":""},{"path":"/reference/get_graph_actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get information on any available graph actions — get_graph_actions","text":"","code":"get_graph_actions(graph)"},{"path":"/reference/get_graph_actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get information on any available graph actions — get_graph_actions","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get information on any available graph actions — get_graph_actions","text":"df_tbl object.","code":""},{"path":"/reference/get_graph_actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get information on any available graph actions — get_graph_actions","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Add a graph action that sets a node # attr column with a function; the # main function `set_node_attr_w_fcn()` # uses the `get_betweenness()` function # to provide betweenness values in the # `btwns` column graph <- graph %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_betweenness\", column_name = \"btwns\", action_name = \"get_btwns\") # To ensure that the action is # available in the graph, use the # `get_graph_actions()` function graph %>% get_graph_actions() #> # A tibble: 1 × 3 #> action_index action_name expression #> #> 1 1 get_btwns set_node_attr_w_fcn(graph = graph, node_attr_fcn = '…"},{"path":"/reference/get_graph_from_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a graph available in a series — get_graph_from_graph_series","title":"Get a graph available in a series — get_graph_from_graph_series","text":"Using graph series object type dgr_graph_1D, get graph object.","code":""},{"path":"/reference/get_graph_from_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a graph available in a series — get_graph_from_graph_series","text":"","code":"get_graph_from_graph_series(graph_series, graph_no)"},{"path":"/reference/get_graph_from_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a graph available in a series — get_graph_from_graph_series","text":"graph_series graph series object type dgr_graph_1D. graph_no index graph graph series.","code":""},{"path":"/reference/get_graph_from_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a graph available in a series — get_graph_from_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Get the second graph in the series extracted_graph <- series %>% get_graph_from_graph_series( graph_no = 2)"},{"path":"/reference/get_graph_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get metrics for a graph — get_graph_info","title":"Get metrics for a graph — get_graph_info","text":"Get data frame metrics graph.","code":""},{"path":"/reference/get_graph_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get metrics for a graph — get_graph_info","text":"","code":"get_graph_info(graph)"},{"path":"/reference/get_graph_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get metrics for a graph — get_graph_info","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get metrics for a graph — get_graph_info","text":"data frame containing metrics pertaining graph","code":""},{"path":"/reference/get_graph_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get metrics for a graph — get_graph_info","text":"","code":"if (FALSE) { # Import a GML graph file available # in the DiagrammeR package karate_club <- system.file( \"extdata\", \"karate.gml\", package = \"DiagrammeR\") %>% import_graph() %>% set_graph_name(\"karate\") # Display a data frame with # graph information karate_club %>% get_graph_info() }"},{"path":"/reference/get_graph_log.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph log information — get_graph_log","title":"Get the graph log information — get_graph_log","text":"Get tibble graph log, contains information functions called graph resulted transformation graph.","code":""},{"path":"/reference/get_graph_log.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph log information — get_graph_log","text":"","code":"get_graph_log(graph)"},{"path":"/reference/get_graph_log.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph log information — get_graph_log","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_log.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph log information — get_graph_log","text":"df_tbl object.","code":""},{"path":"/reference/get_graph_log.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph log information — get_graph_log","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function and # delete 2 nodes from the graph graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) %>% delete_node(node = 5) %>% delete_node(node = 7) # Get the graph log, which is a # record of all graph transformations graph %>% get_graph_log() #> # A tibble: 4 × 8 #> version_id function_used time_modified duration nodes edges d_n d_e #> #> 1 1 create_graph 2023-11-09 02:20:46 0.00300 0 0 0 0 #> 2 2 add_gnm_graph 2023-11-09 02:20:46 0.0111 10 15 10 15 #> 3 3 delete_node 2023-11-09 02:20:46 0.0146 9 11 -1 -4 #> 4 4 delete_node 2023-11-09 02:20:46 0.0179 8 8 -1 -3"},{"path":"/reference/get_graph_name.html","id":null,"dir":"Reference","previous_headings":"","what":"Get graph name — get_graph_name","title":"Get graph name — get_graph_name","text":"Get name graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_name.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get graph name — get_graph_name","text":"","code":"get_graph_name(graph)"},{"path":"/reference/get_graph_name.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get graph name — get_graph_name","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_name.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get graph name — get_graph_name","text":"single-length character vector assigned graph name. graph name set, NA returned.","code":""},{"path":"/reference/get_graph_name.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get graph name — get_graph_name","text":"","code":"# Create an empty graph graph <- create_graph() # Provide the new graph with a name graph <- set_graph_name( graph, name = \"the_name\") # Get the graph's name graph %>% get_graph_name() #> [1] \"the_name\""},{"path":"/reference/get_graph_series_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get information on a graph series — get_graph_series_info","title":"Get information on a graph series — get_graph_series_info","text":"Obtain data frame information graphs within graph series.","code":""},{"path":"/reference/get_graph_series_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get information on a graph series — get_graph_series_info","text":"","code":"get_graph_series_info(graph_series)"},{"path":"/reference/get_graph_series_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get information on a graph series — get_graph_series_info","text":"graph_series graph series object type dgr_graph_1D.","code":""},{"path":"/reference/get_graph_series_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get information on a graph series — get_graph_series_info","text":"data frame containing information graphs within supplied graph series.","code":""},{"path":"/reference/get_graph_series_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get information on a graph series — get_graph_series_info","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Get information on the graphs in the series series %>% get_graph_series_info() #> graph name date_time tz nodes edges directed #> 1 1 graph_SVUyR63K 2023-11-09 02:20:47 UTC 4 3 TRUE #> 2 2 graph_SueySz3B 2023-11-09 02:20:47 UTC 5 5 TRUE #> 3 3 graph_HYG7a9jw 2023-11-09 02:20:47 UTC 6 5 TRUE"},{"path":"/reference/get_graph_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph date-time or timezone — get_graph_time","title":"Get the graph date-time or timezone — get_graph_time","text":"Get time timezone graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph date-time or timezone — get_graph_time","text":"","code":"get_graph_time(graph)"},{"path":"/reference/get_graph_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph date-time or timezone — get_graph_time","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_graph_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph date-time or timezone — get_graph_time","text":"single-length POSIXct vector assigned graph time.","code":""},{"path":"/reference/get_graph_time.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph date-time or timezone — get_graph_time","text":"","code":"# Create an empty graph and # set the graph's time; if nothing # is supplied for the `tz` argument, # `GMT` is used as the time zone graph <- create_graph() %>% set_graph_time( time = \"2015-10-25 15:23:00\") # Get the graph's time as a POSIXct # object using `get_graph_time()` graph %>% get_graph_time() #> [1] \"2015-10-25 15:23:00 UTC\""},{"path":"/reference/get_jaccard_similarity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"Get Jaccard similarity coefficient scores one nodes graph.","code":""},{"path":"/reference/get_jaccard_similarity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"","code":"get_jaccard_similarity(graph, nodes = NULL, direction = \"all\", round_to = 3)"},{"path":"/reference/get_jaccard_similarity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"graph graph object class dgr_graph. nodes optional vector node IDs consider Jaccard similarity scores. supplied, similarity scores provided every pair nodes graph. direction Using (default), function ignore edge direction determining scores neighboring nodes. , edge direction neighboring nodes considered. round_to maximum number decimal places retain Jaccard similarity coefficient scores. default value 3.","code":""},{"path":"/reference/get_jaccard_similarity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"matrix Jaccard similarity values pair nodes considered.","code":""},{"path":"/reference/get_jaccard_similarity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get Jaccard similarity coefficient scores — get_jaccard_similarity","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the Jaccard similarity # values for nodes `5`, `6`, # and `7` graph %>% get_jaccard_similarity( nodes = 5:7) #> 5 6 7 #> 5 1.000 0.286 0.400 #> 6 0.286 1.000 0.333 #> 7 0.400 0.333 1.000"},{"path":"/reference/get_last_edges_created.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the last set of edges created in a graph — get_last_edges_created","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"Get last edges created graph object class dgr_graph. function ideally used just creating edges.","code":""},{"path":"/reference/get_last_edges_created.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"","code":"get_last_edges_created(graph)"},{"path":"/reference/get_last_edges_created.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_last_edges_created.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"vector edge ID values.","code":""},{"path":"/reference/get_last_edges_created.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the last set of edges created in a graph — get_last_edges_created","text":"","code":"# Create a graph and add a cycle and then # a tree in 2 separate function calls graph <- create_graph() %>% add_cycle( n = 3, rel = \"a\") %>% add_balanced_tree( k = 2, h = 2, rel = \"b\") # Get the last edges created (all edges # from the tree) graph %>% get_last_edges_created() #> [1] 4 5 6 7 8 9"},{"path":"/reference/get_last_nodes_created.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the last set of nodes created in a graph — get_last_nodes_created","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"Get last nodes created graph object class dgr_graph. Provides vector node ID values. function ideally used just creating nodes.","code":""},{"path":"/reference/get_last_nodes_created.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"","code":"get_last_nodes_created(graph)"},{"path":"/reference/get_last_nodes_created.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_last_nodes_created.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"vector node ID values.","code":""},{"path":"/reference/get_last_nodes_created.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the last set of nodes created in a graph — get_last_nodes_created","text":"","code":"# Create a graph and add 4 nodes # in 2 separate function calls graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"a_1\", \"a_2\")) %>% add_n_nodes( n = 2, type = \"b\", label = c(\"b_1\", \"b_2\")) # Get the last nodes created (2 nodes # from the last function call) graph %>% get_last_nodes_created() #> [1] 3 4"},{"path":"/reference/get_leverage_centrality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get leverage centrality — get_leverage_centrality","title":"Get leverage centrality — get_leverage_centrality","text":"Get leverage centrality values nodes graph. Leverage centrality measure relationship degree given node degree neighbors, averaged neighbors. node negative leverage centrality influenced neighbors, neighbors connect interact far nodes. node positive leverage centrality influences neighbors since neighbors tend far fewer connections.","code":""},{"path":"/reference/get_leverage_centrality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get leverage centrality — get_leverage_centrality","text":"","code":"get_leverage_centrality(graph)"},{"path":"/reference/get_leverage_centrality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get leverage centrality — get_leverage_centrality","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_leverage_centrality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get leverage centrality — get_leverage_centrality","text":"data frame leverage centrality values nodes.","code":""},{"path":"/reference/get_leverage_centrality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get leverage centrality — get_leverage_centrality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph( directed = FALSE) %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get leverage centrality values # for all nodes in the graph graph %>% get_leverage_centrality() #> id leverage_centrality #> 1 1 -0.1964 #> 2 2 -0.1964 #> 3 3 -0.3810 #> 4 4 0.0556 #> 5 5 -0.0556 #> 6 6 0.0556 #> 7 7 -0.1964 #> 8 8 -0.3810 #> 9 9 -0.1964 #> 10 10 -1.0000 # Add the leverage centrality # values to the graph as a # node attribute graph <- graph %>% join_node_attrs( df = get_leverage_centrality(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label leverage_centrality #> 1 1 1 -0.1964 #> 2 2 2 -0.1964 #> 3 3 3 -0.3810 #> 4 4 4 0.0556 #> 5 5 5 -0.0556 #> 6 6 6 0.0556 #> 7 7 7 -0.1964 #> 8 8 8 -0.3810 #> 9 9 9 -0.1964 #> 10 10 10 -1.0000"},{"path":"/reference/get_max_eccentricity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the maximum graph eccentricity — get_max_eccentricity","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"Get diameter graph, largest eccentricity graph. graph eccentricity node shortest path farthest node graph.","code":""},{"path":"/reference/get_max_eccentricity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"","code":"get_max_eccentricity(graph)"},{"path":"/reference/get_max_eccentricity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_max_eccentricity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"single numeric value representing maximum eccentricity graph.","code":""},{"path":"/reference/get_max_eccentricity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the maximum graph eccentricity — get_max_eccentricity","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the graph's maximum # eccentricity graph %>% get_max_eccentricity() #> [1] 4 # Create a full graph and then # get the maximum eccentricity # value for that create_graph() %>% add_full_graph(n = 10) %>% get_max_eccentricity() #> [1] 1"},{"path":"/reference/get_mean_distance.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the mean distance — get_mean_distance","title":"Get the mean distance — get_mean_distance","text":"Get mean distance graph, average path length graph. operates calculation shortest paths pairs nodes.","code":""},{"path":"/reference/get_mean_distance.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the mean distance — get_mean_distance","text":"","code":"get_mean_distance(graph)"},{"path":"/reference/get_mean_distance.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the mean distance — get_mean_distance","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_mean_distance.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the mean distance — get_mean_distance","text":"single numeric value representing mean distance graph.","code":""},{"path":"/reference/get_mean_distance.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the mean distance — get_mean_distance","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the mean distance graph %>% get_mean_distance() #> [1] 2.5 # Create a full graph and then # get the mean distance value create_graph() %>% add_full_graph(n = 10) %>% get_mean_distance() #> [1] 1"},{"path":"/reference/get_min_cut_between.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the minimum cut between source and sink nodes — get_min_cut_between","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"Get minimum cut source sink nodes. minimum total capacity edges needed removal order eliminate paths source sink nodes.","code":""},{"path":"/reference/get_min_cut_between.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"","code":"get_min_cut_between(graph, from, to)"},{"path":"/reference/get_min_cut_between.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"graph graph object class dgr_graph. node ID source node. node ID sink target node.","code":""},{"path":"/reference/get_min_cut_between.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"single numeric value representing minimum total edge capacity removed disconnect source sink nodes.","code":""},{"path":"/reference/get_min_cut_between.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the minimum cut between source and sink nodes — get_min_cut_between","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the minimum cut # between nodes `1` and `4` graph %>% get_min_cut_between( from = 1, to = 2) #> [1] 1 # Create a cycle graph with # randomized values given to all # edges as the `capacity` attribute graph_capacity <- create_graph() %>% add_cycle(n = 5) %>% select_edges() %>% set_edge_attrs_ws( edge_attr = capacity, value = rnorm( n = count_edges(.), mean = 5, sd = 1)) %>% clear_selection() # Determine the minimum cut # between nodes `1` and `4` for # this graph, where `capacity`is # set as an edge attribute graph_capacity %>% get_min_cut_between( from = 1, to = 2) #> [1] 4.479822 # Create a full graph and then # get the minimum cut requirement # between nodes `2` and `8` create_graph() %>% add_full_graph(n = 10) %>% get_min_cut_between( from = 2, to = 8) #> [1] 9"},{"path":"/reference/get_min_eccentricity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the minimum graph eccentricity — get_min_eccentricity","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"Get radius graph, smallest eccentricity graph. graph eccentricity node shortest path farthest node graph.","code":""},{"path":"/reference/get_min_eccentricity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"","code":"get_min_eccentricity(graph, direction = \"all\")"},{"path":"/reference/get_min_eccentricity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"graph graph object class dgr_graph. direction Using (default), search ignore edge direction traversing graph. , measurements paths node whereas , measurements paths node.","code":""},{"path":"/reference/get_min_eccentricity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"single numeric value representing minimum eccentricity graph.","code":""},{"path":"/reference/get_min_eccentricity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the minimum graph eccentricity — get_min_eccentricity","text":"","code":"# Create a cycle graph graph <- create_graph() %>% add_cycle(n = 5) # Determine the graph's minimum # eccentricity graph %>% get_min_eccentricity() #> [1] 2 # Create a full graph and then # get the minimum eccentricity # value for that create_graph() %>% add_full_graph(n = 10) %>% get_min_eccentricity() #> [1] 1"},{"path":"/reference/get_multiedge_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the count of multiple edges — get_multiedge_count","title":"Get the count of multiple edges — get_multiedge_count","text":"Get count number multiple edges graph. Included count number separate edges share edge definition (.e., pair nodes) across entire graph. , example, 2 edge definitions graph involve 6 separate edge IDs, count 4.","code":""},{"path":"/reference/get_multiedge_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the count of multiple edges — get_multiedge_count","text":"","code":"get_multiedge_count(graph)"},{"path":"/reference/get_multiedge_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the count of multiple edges — get_multiedge_count","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_multiedge_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the count of multiple edges — get_multiedge_count","text":"vector single, numerical value.","code":""},{"path":"/reference/get_multiedge_count.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the count of multiple edges — get_multiedge_count","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 5, label = TRUE) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 4, 4, 3, 5, 1, 3, 4), to = c(4, 1, 1, 2, 2, 2, 2, 1)) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get the total number of multiple # edges (those edges that share an # edge definition) in the graph graph %>% get_multiedge_count() #> [1] 3"},{"path":"/reference/get_nbrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get all neighbors of one or more nodes — get_nbrs","title":"Get all neighbors of one or more nodes — get_nbrs","text":"one nodes, get set neighboring nodes.","code":""},{"path":"/reference/get_nbrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get all neighbors of one or more nodes — get_nbrs","text":"","code":"get_nbrs(graph, nodes)"},{"path":"/reference/get_nbrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get all neighbors of one or more nodes — get_nbrs","text":"graph graph object class dgr_graph. nodes vector node ID values.","code":""},{"path":"/reference/get_nbrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get all neighbors of one or more nodes — get_nbrs","text":"vector node ID values.","code":""},{"path":"/reference/get_nbrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get all neighbors of one or more nodes — get_nbrs","text":"","code":"# Create a simple, directed graph with 5 # nodes and 4 edges graph <- create_graph() %>% add_path(n = 5) # Find all neighbor nodes for node `2` graph %>% get_nbrs(nodes = 2) #> [1] 1 3 # Find all neighbor nodes for nodes `1` # and `5` graph %>% get_nbrs(nodes = c(1, 5)) #> [1] 2 4 # Color node `3` with purple, get its # neighbors and color those nodes green graph <- graph %>% select_nodes_by_id(nodes = 3) %>% set_node_attrs_ws( node_attr = color, value = \"purple\") %>% clear_selection() %>% select_nodes_by_id( nodes = get_nbrs( graph = ., nodes = 3)) %>% set_node_attrs_ws( node_attr = color, value = \"green\")"},{"path":"/reference/get_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node attribute values — get_node_attrs","title":"Get node attribute values — get_node_attrs","text":"graph object class dgr_graph, get node attribute values one nodes.","code":""},{"path":"/reference/get_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node attribute values — get_node_attrs","text":"","code":"get_node_attrs(graph, node_attr, nodes = NULL)"},{"path":"/reference/get_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node attribute values — get_node_attrs","text":"graph graph object class dgr_graph. node_attr name attribute get values. nodes optional vector node IDs filtering list nodes present graph node data frame.","code":""},{"path":"/reference/get_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node attribute values — get_node_attrs","text":"named vector node attribute values attribute given node_attr node ID.","code":""},{"path":"/reference/get_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node attribute values — get_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_node_attrs( node_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # Get all of the values from # the `value` node attribute # as a named vector graph %>% get_node_attrs( node_attr = value) #> 1 2 3 4 #> 2.5 8.2 4.2 2.4 # To only return node attribute # values for specified nodes, # use the `nodes` argument graph %>% get_node_attrs( node_attr = value, nodes = c(1, 3)) #> 1 3 #> 2.5 4.2"},{"path":"/reference/get_node_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node attribute values from a selection of nodes — get_node_attrs_ws","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"graph object class dgr_graph, get node attribute values nodes currently active selection. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/get_node_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"","code":"get_node_attrs_ws(graph, node_attr)"},{"path":"/reference/get_node_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"graph graph object class dgr_graph. node_attr name attribute get values.","code":""},{"path":"/reference/get_node_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"named vector node attribute values attribute given node_attr node ID.","code":""},{"path":"/reference/get_node_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node attribute values from a selection of nodes — get_node_attrs_ws","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_node_attrs( node_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # Select nodes with ID values # `1` and `3` graph <- graph %>% select_nodes_by_id( nodes = c(1, 3)) # Get the node attribute values # for the `value` attribute, limited # to the current node selection graph %>% get_node_attrs_ws( node_attr = value) #> 1 3 #> 2.5 4.2"},{"path":"/reference/get_node_df.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a node data frame from a graph — get_node_df","title":"Get a node data frame from a graph — get_node_df","text":"graph, obtain node data frame current node attributes.","code":""},{"path":"/reference/get_node_df.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a node data frame from a graph — get_node_df","text":"","code":"get_node_df(graph)"},{"path":"/reference/get_node_df.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a node data frame from a graph — get_node_df","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_node_df.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a node data frame from a graph — get_node_df","text":"node data frame.","code":""},{"path":"/reference/get_node_df.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a node data frame from a graph — get_node_df","text":"","code":"# Create a graph graph <- create_graph() %>% add_n_nodes( n = 1, type = \"a\") %>% select_last_nodes_created() %>% add_n_nodes_ws( n = 5, direction = \"from\", type = \"b\") %>% select_nodes_by_id( nodes = 1) %>% set_node_attrs_ws( node_attr = value, value = 25.3) %>% clear_selection() %>% select_nodes_by_id( nodes = 2:4) %>% set_node_attrs_ws( node_attr = color, value = \"grey70\") %>% invert_selection() %>% set_node_attrs_ws( node_attr = color, value = \"grey80\") %>% clear_selection() # Get the graph's internal node # data frame (ndf) graph %>% get_node_df() #> id type label value color #> 1 1 a 25.3 grey80 #> 2 2 b NA grey70 #> 3 3 b NA grey70 #> 4 4 b NA grey70 #> 5 5 b NA grey80 #> 6 6 b NA grey80"},{"path":"/reference/get_node_df_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"graph object class dgr_graph, get graph's internal node data frame filtered node ID values currently active selection. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/get_node_df_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"","code":"get_node_df_ws(graph)"},{"path":"/reference/get_node_df_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_node_df_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"node data frame.","code":""},{"path":"/reference/get_node_df_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph's ndf filtered by a selection of nodes — get_node_df_ws","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_node_attrs( node_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # Select nodes with ID values # `1` and `3` graph <- graph %>% select_nodes_by_id( nodes = c(1, 3)) # Get the node data frame that's # limited to the rows that correspond # to the node selection graph %>% get_node_df_ws() #> id type label value #> 1 1 1 2.5 #> 2 3 3 4.2"},{"path":"/reference/get_node_ids.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a vector of node ID values — get_node_ids","title":"Get a vector of node ID values — get_node_ids","text":"Obtain vector node ID values graph object. optional filter node attribute can limit set node ID values returned.","code":""},{"path":"/reference/get_node_ids.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a vector of node ID values — get_node_ids","text":"","code":"get_node_ids(graph, conditions = NULL)"},{"path":"/reference/get_node_ids.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a vector of node ID values — get_node_ids","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval nodes.","code":""},{"path":"/reference/get_node_ids.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a vector of node ID values — get_node_ids","text":"vector node ID values.","code":""},{"path":"/reference/get_node_ids.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a vector of node ID values — get_node_ids","text":"","code":"# Create a node data # frame (ndf) ndf <- create_node_df( n = 4, type = \"letter\", color = c( \"red\", \"green\", \"blue\", \"blue\"), value = c( 3.5, 2.6, 9.4, 2.7)) # Create a graph using # the ndf graph <- create_graph( nodes_df = ndf) # Get a vector of all nodes in a graph graph %>% get_node_ids() #> [1] 1 2 3 4 # Get a vector of node ID values using a # numeric comparison (i.e., all nodes with # `value` attribute greater than 3) graph %>% get_node_ids( conditions = value > 3) #> [1] 1 3 # Get a vector of node ID values using # a match pattern (i.e., all nodes with # `color` attribute of `green`) graph %>% get_node_ids( conditions = color == \"green\") #> [1] 2 # Use multiple conditions to return nodes # with the desired attribute values graph %>% get_node_ids( conditions = color == \"blue\" & value > 5) #> [1] 3"},{"path":"/reference/get_node_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Get detailed information on nodes — get_node_info","title":"Get detailed information on nodes — get_node_info","text":"Obtain data frame detailed information nodes interrelationships within graph.","code":""},{"path":"/reference/get_node_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get detailed information on nodes — get_node_info","text":"","code":"get_node_info(graph)"},{"path":"/reference/get_node_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get detailed information on nodes — get_node_info","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_node_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get detailed information on nodes — get_node_info","text":"data frame containing information specific node within graph.","code":""},{"path":"/reference/get_node_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get detailed information on nodes — get_node_info","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) # Get information on the graph's nodes graph %>% get_node_info() #> id type label deg indeg outdeg loops #> 1 1 1 4 3 1 0 #> 2 2 2 4 1 3 0 #> 3 3 3 6 2 4 0 #> 4 4 4 3 2 1 0 #> 5 5 5 3 2 1 0"},{"path":"/reference/get_non_nbrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get non-neighbors of a node in a graph — get_non_nbrs","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"Get set nodes neighboring single graph node.","code":""},{"path":"/reference/get_non_nbrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"","code":"get_non_nbrs(graph, node)"},{"path":"/reference/get_non_nbrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"graph graph object class dgr_graph. node single-length vector containing node ID value.","code":""},{"path":"/reference/get_non_nbrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"vector node ID values.","code":""},{"path":"/reference/get_non_nbrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get non-neighbors of a node in a graph — get_non_nbrs","text":"","code":"# Create a simple, directed graph with 5 # nodes and 4 edges graph <- create_graph() %>% add_path(n = 5) # Find all non-neighbors of node `2` graph %>% get_non_nbrs(node = 2) #> [1] 4 5"},{"path":"/reference/get_pagerank.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the PageRank values for all nodes — get_pagerank","title":"Get the PageRank values for all nodes — get_pagerank","text":"Get PageRank values nodes graph.","code":""},{"path":"/reference/get_pagerank.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the PageRank values for all nodes — get_pagerank","text":"","code":"get_pagerank(graph, directed = TRUE, damping = 0.85)"},{"path":"/reference/get_pagerank.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the PageRank values for all nodes — get_pagerank","text":"graph graph object class dgr_graph. directed TRUE (default) directed paths considered directed graphs. ignored undirected graphs. damping damping factor. default value set 0.85.","code":""},{"path":"/reference/get_pagerank.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the PageRank values for all nodes — get_pagerank","text":"data frame PageRank values nodes.","code":""},{"path":"/reference/get_pagerank.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the PageRank values for all nodes — get_pagerank","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the PageRank scores # for all nodes in the graph graph %>% get_pagerank() #> id pagerank #> 1 1 0.1302 #> 2 2 0.1037 #> 3 3 0.0450 #> 4 4 0.0450 #> 5 5 0.1501 #> 6 6 0.0578 #> 7 7 0.0871 #> 8 8 0.1780 #> 9 9 0.0744 #> 10 10 0.1287 # Colorize nodes according to their # PageRank scores graph <- graph %>% join_node_attrs( df = get_pagerank(graph = .)) %>% colorize_node_attrs( node_attr_from = pagerank, node_attr_to = fillcolor, palette = \"RdYlGn\")"},{"path":"/reference/get_paths.html","id":null,"dir":"Reference","previous_headings":"","what":"Get paths from a specified node in a directed graph — get_paths","title":"Get paths from a specified node in a directed graph — get_paths","text":"Obtain list possible paths given node within directed graph.","code":""},{"path":"/reference/get_paths.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get paths from a specified node in a directed graph — get_paths","text":"","code":"get_paths( graph, from = NULL, to = NULL, shortest_path = FALSE, longest_path = FALSE, distance = NULL )"},{"path":"/reference/get_paths.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get paths from a specified node in a directed graph — get_paths","text":"graph graph object class dgr_graph. node paths determined. node paths determined. shortest_path option return paths shortest set determined paths. longest_path option return paths longest set determined paths. distance vector integer values specify valid paths return filtering distance.","code":""},{"path":"/reference/get_paths.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get paths from a specified node in a directed graph — get_paths","text":"list paths, sorted ascending traversal length, comprising vectors node IDs sequence traversal graph.","code":""},{"path":"/reference/get_paths.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get paths from a specified node in a directed graph — get_paths","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_n_nodes(n = 8) %>% add_edge(from = 1, to = 2) %>% add_edge(from = 1, to = 3) %>% add_edge(from = 3, to = 4) %>% add_edge(from = 3, to = 5) %>% add_edge(from = 4, to = 6) %>% add_edge(from = 2, to = 7) %>% add_edge(from = 7, to = 5) %>% add_edge(from = 4, to = 8) # Get a list of all paths outward from node `1` graph %>% get_paths(from = 1) #> [[1]] #> [1] 1 3 5 #> #> [[2]] #> [1] 1 2 7 5 #> #> [[3]] #> [1] 1 3 4 6 #> #> [[4]] #> [1] 1 3 4 8 #> # Get a list of all paths leading to node `6` graph %>% get_paths(to = 6) #> [[1]] #> [1] 1 3 4 6 #> # Get a list of all paths from `1` to `5` graph %>% get_paths( from = 1, to = 5) #> [[1]] #> [1] 1 3 5 #> #> [[2]] #> [1] 1 2 7 5 #> # Get a list of all paths from `1` up to a distance # of 2 node traversals graph %>% get_paths( from = 1, distance = 2) #> [[1]] #> [1] 1 3 5 #> #> [[2]] #> [1] 1 2 7 #> #> [[3]] #> [1] 1 3 4 #> # Get a list of the shortest paths from `1` to `5` get_paths( graph, from = 1, to = 5, shortest_path = TRUE) #> [[1]] #> [1] 1 3 5 #> # Get a list of the longest paths from `1` to `5` get_paths( graph, from = 1, to = 5, longest_path = TRUE) #> [[1]] #> [1] 1 2 7 5 #>"},{"path":"/reference/get_periphery.html","id":null,"dir":"Reference","previous_headings":"","what":"Get nodes that form the graph periphery — get_periphery","title":"Get nodes that form the graph periphery — get_periphery","text":"Get nodes part graph periphery (.e., maximum eccentricity graph).","code":""},{"path":"/reference/get_periphery.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get nodes that form the graph periphery — get_periphery","text":"","code":"get_periphery(graph)"},{"path":"/reference/get_periphery.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get nodes that form the graph periphery — get_periphery","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_periphery.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get nodes that form the graph periphery — get_periphery","text":"vector node IDs.","code":""},{"path":"/reference/get_periphery.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get nodes that form the graph periphery — get_periphery","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function and # get the nodes in the graph periphery create_graph() %>% add_gnm_graph( n = 28, m = 35, set_seed = 23) %>% get_periphery() #> [1] 6 9 25 28"},{"path":"/reference/get_predecessors.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node IDs for predecessor nodes to the specified node — get_predecessors","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"Provides vector node IDs nodes connection given node.","code":""},{"path":"/reference/get_predecessors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"","code":"get_predecessors(graph, node)"},{"path":"/reference/get_predecessors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"graph graph object class dgr_graph. node node ID selected node.","code":""},{"path":"/reference/get_predecessors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"vector node ID values.","code":""},{"path":"/reference/get_predecessors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node IDs for predecessor nodes to the specified node — get_predecessors","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a node data frame (ndf) ndf <- create_node_df(n = 26) # Create an edge data # frame (edf) edf <- create_edge_df( from = sample( 1:26, replace = TRUE), to = sample( 1:26, replace = TRUE)) # From the ndf and edf, # create a graph object graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get predecessors for node # `23` in the graph graph %>% get_predecessors( node = 23) #> [1] 6 # If there are no predecessors, # `NA` is returned graph %>% get_predecessors( node = 26) #> [1] NA"},{"path":"/reference/get_radiality.html","id":null,"dir":"Reference","previous_headings":"","what":"Get radiality centrality scores — get_radiality","title":"Get radiality centrality scores — get_radiality","text":"Get radiality centrality nodes graph. scores describe ease nodes can reach nodes.","code":""},{"path":"/reference/get_radiality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get radiality centrality scores — get_radiality","text":"","code":"get_radiality(graph, direction = \"all\")"},{"path":"/reference/get_radiality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get radiality centrality scores — get_radiality","text":"graph graph object class dgr_graph. direction Using (default), search ignore edge direction traversing graph. , measurements paths node whereas , measurements paths node.","code":""},{"path":"/reference/get_radiality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get radiality centrality scores — get_radiality","text":"data frame radiality centrality scores nodes.","code":""},{"path":"/reference/get_radiality.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get radiality centrality scores — get_radiality","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get the radiality scores for nodes in the graph graph %>% get_radiality() #> id radiality #> 1 1 2.3333 #> 2 2 3.0000 #> 3 3 2.6667 #> 4 4 2.8889 #> 5 5 2.5556 #> 6 6 2.4444 #> 7 7 2.6667 #> 8 8 2.7778 #> 9 9 2.1111 #> 10 10 2.3333 # Add the radiality values # to the graph as a node # attribute graph <- graph %>% join_node_attrs( df = get_radiality(.)) # Display the graph's node data frame graph %>% get_node_df() #> id type label radiality #> 1 1 1 2.3333 #> 2 2 2 3.0000 #> 3 3 3 2.6667 #> 4 4 4 2.8889 #> 5 5 5 2.5556 #> 6 6 6 2.4444 #> 7 7 7 2.6667 #> 8 8 8 2.7778 #> 9 9 9 2.1111 #> 10 10 10 2.3333"},{"path":"/reference/get_reciprocity.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the graph reciprocity — get_reciprocity","title":"Get the graph reciprocity — get_reciprocity","text":"Get reciprocity directed graph. reciprocity graph fraction reciprocal edges (e.g., 1 -> 2 2 -> 1) edges available graph. Note undirected graph, edges reciprocal. function consider loop edges (e.g., 1 -> 1).","code":""},{"path":"/reference/get_reciprocity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the graph reciprocity — get_reciprocity","text":"","code":"get_reciprocity(graph)"},{"path":"/reference/get_reciprocity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the graph reciprocity — get_reciprocity","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_reciprocity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the graph reciprocity — get_reciprocity","text":"single, numerical value ratio value reciprocal edges graph edges.","code":""},{"path":"/reference/get_reciprocity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the graph reciprocity — get_reciprocity","text":"","code":"# Define a graph where 2 edge definitions # have pairs of reciprocal edges graph <- create_graph() %>% add_cycle(n = 3) %>% add_node( from = 1, to = 1) %>% add_node( from = 1, to = 1) # Get the graph reciprocity, which will # be calculated as the ratio 4/7 (where # 4 is the number reciprocating edges # and 7 is the total number of edges # in the graph) graph %>% get_reciprocity() #> [1] 0.5714286 # For an undirected graph, all edges # are reciprocal, so the ratio will # always be 1 graph %>% set_graph_undirected() %>% get_reciprocity() #> [1] 1 # For a graph with no edges, the graph # reciprocity cannot be determined (and # the same NA result is obtained from an # empty graph) create_graph() %>% add_n_nodes(n = 5) %>% get_reciprocity() #> [1] NA"},{"path":"/reference/get_s_connected_cmpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Get nodes within strongly connected components — get_s_connected_cmpts","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"Determine nodes graph belong different strongly connected components.","code":""},{"path":"/reference/get_s_connected_cmpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"","code":"get_s_connected_cmpts(graph)"},{"path":"/reference/get_s_connected_cmpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_s_connected_cmpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"data frame nodes membership different strongly connected components.","code":""},{"path":"/reference/get_s_connected_cmpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get nodes within strongly connected components — get_s_connected_cmpts","text":"","code":"suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a graph with a random # connection between 2 different # node cycles graph <- create_graph() %>% add_cycle( n = 3, type = \"cycle_1\") %>% add_cycle( n = 4, type = \"cycle_2\") %>% add_edge( from = get_node_ids( graph = ., conditions = type == \"cycle_1\") %>% sample(size = 1), to = get_node_ids( graph = ., conditions = type == \"cycle_2\") %>% sample(size = 1)) # Get the strongly connected # components as a data frame of # nodes and their groupings graph %>% get_s_connected_cmpts() #> id sc_component #> 1 1 1 #> 2 2 1 #> 3 3 1 #> 4 4 2 #> 5 5 2 #> 6 6 2 #> 7 7 2"},{"path":"/reference/get_selection.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the current selection available in a graph object — get_selection","title":"Get the current selection available in a graph object — get_selection","text":"Get current selection node IDs edge IDs graph object class dgr_graph.","code":""},{"path":"/reference/get_selection.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the current selection available in a graph object — get_selection","text":"","code":"get_selection(graph)"},{"path":"/reference/get_selection.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the current selection available in a graph object — get_selection","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_selection.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the current selection available in a graph object — get_selection","text":"vector current selection node edge ID values.","code":""},{"path":"/reference/get_selection.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the current selection available in a graph object — get_selection","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_path(n = 6) # Select node `4`, then select # all nodes a distance of 1 away # from node `4`, and finally # return the selection of nodes as # a vector object graph %>% select_nodes(nodes = 4) %>% select_nodes_in_neighborhood( node = 4, distance = 1) %>% get_selection() #> [1] 3 4 5 # Select edges associated with # node `4` and return the # selection of edges graph %>% select_edges_by_node_id( nodes = 4) %>% get_selection() #> [1] 3 4"},{"path":"/reference/get_similar_nbrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"graph single node serving starting point, get nodes potential neighborhood nodes (adjacent starting node) common similar (within threshold values) node attribute starting node.","code":""},{"path":"/reference/get_similar_nbrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"","code":"get_similar_nbrs(graph, node, node_attr, tol_abs = NULL, tol_pct = NULL)"},{"path":"/reference/get_similar_nbrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"graph graph object class dgr_graph. node single-length vector containing node ID value. node_attr name node attribute use compare adjacent nodes. tol_abs values contained node attribute node_attr numeric, one can optionally supply numeric vector length 2 provides lower upper numeric bound criteria neighboring node similarity starting node. tol_pct values contained node attribute node_attr numeric, one can optionally supply numeric vector length 2 specifies lower upper bounds negative positive percentage changes value starting node. bounds serve criteria neighboring node similarity starting node.","code":""},{"path":"/reference/get_similar_nbrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"vector node ID values.","code":""},{"path":"/reference/get_similar_nbrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get neighboring nodes based on node attribute similarity — get_similar_nbrs","text":"","code":"# Getting similar neighbors can # be done through numerical comparisons; # start by creating a random, directed # graph with 18 nodes and 22 edges # using the `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 18, m = 25, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(0)) # Starting with node `10`, we # can test whether any nodes # adjacent and beyond are # numerically equivalent in `value` graph %>% get_similar_nbrs( node = 10, node_attr = value) #> [1] 2 14 # We can also set a tolerance # for ascribing similarly by using # either the `tol_abs` or `tol_pct` # arguments (the first applies absolute # lower and upper bounds from the # value in the starting node and the # latter uses a percentage difference # to do the same); try setting `tol_abs` # with a fairly large range to # determine if several nodes can be # selected graph %>% get_similar_nbrs( node = 10, node_attr = value, tol_abs = c(1, 1)) #> [1] 1 2 9 14 # That resulted in a fairly large # set of 4 neigboring nodes; for # sake of example, setting the range # to be very large will effectively # return all nodes in the graph # except for the starting node graph %>% get_similar_nbrs( node = 10, node_attr = value, tol_abs = c(10, 10)) %>% length() #> [1] 17"},{"path":"/reference/get_successors.html","id":null,"dir":"Reference","previous_headings":"","what":"Get node IDs for successor nodes to the specified node — get_successors","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"Provides vector node IDs nodes connection given node.","code":""},{"path":"/reference/get_successors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"","code":"get_successors(graph, node)"},{"path":"/reference/get_successors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"graph graph object class dgr_graph. node node ID selected node.","code":""},{"path":"/reference/get_successors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"vector node ID values.","code":""},{"path":"/reference/get_successors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get node IDs for successor nodes to the specified node — get_successors","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a node data frame (ndf) ndf <- create_node_df(n = 26) # Create an edge data # frame (edf) edf <- create_edge_df( from = sample( 1:26, replace = TRUE), to = sample( 1:26, replace = TRUE)) # From the ndf and edf, # create a graph object graph <- create_graph( nodes_df = ndf, edges_df = edf) # Get sucessors for node # `4` in the graph graph %>% get_successors( node = 4) #> [1] 3 8 # If there are no successors, # NA is returned graph %>% get_successors( node = 1) #> [1] NA"},{"path":"/reference/get_w_connected_cmpts.html","id":null,"dir":"Reference","previous_headings":"","what":"Get all nodes associated with connected components — get_w_connected_cmpts","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"Determine nodes graph belong different weakly connected components (.e., distinct sets nodes traversable paths node set).","code":""},{"path":"/reference/get_w_connected_cmpts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"","code":"get_w_connected_cmpts(graph)"},{"path":"/reference/get_w_connected_cmpts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/get_w_connected_cmpts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"data frame nodes membership different weakly connected components.","code":""},{"path":"/reference/get_w_connected_cmpts.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get all nodes associated with connected components — get_w_connected_cmpts","text":"","code":"# Create a graph with 2 cycles graph <- create_graph() %>% add_cycle(n = 4) %>% add_cycle(n = 3) # Check if the graph is connected graph %>% is_graph_connected() #> [1] FALSE # Get the graph's weakly-connected # components graph %>% get_w_connected_cmpts() #> id wc_component #> 1 1 1 #> 2 2 1 #> 3 3 1 #> 4 4 1 #> 5 5 2 #> 6 6 2 #> 7 7 2"},{"path":"/reference/grViz.html","id":null,"dir":"Reference","previous_headings":"","what":"R + viz.js — grViz","title":"R + viz.js — grViz","text":"Make diagrams R using viz.js infrastructure provided htmlwidgets.","code":""},{"path":"/reference/grViz.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"R + viz.js — grViz","text":"","code":"grViz( diagram = \"\", engine = \"dot\", allow_subst = TRUE, options = NULL, width = NULL, height = NULL, envir = parent.frame() )"},{"path":"/reference/grViz.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"R + viz.js — grViz","text":"diagram Spec diagram either text, filename string, file connection. engine String Graphviz layout engine; can dot (default), neato, circo, twopi. allow_subst boolean enables/disables substitution functionality. options Parameters supplied htmlwidgets framework. width optional parameter specifying width resulting graphic pixels. height optional parameter specifying height resulting graphic pixels. envir environment substitution functionality takes place.","code":""},{"path":"/reference/grViz.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"R + viz.js — grViz","text":"object class htmlwidget intelligently print HTML variety contexts including R console, within R Markdown documents, within Shiny output bindings.","code":""},{"path":"/reference/grVizOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Widget output function for use in Shiny — grVizOutput","title":"Widget output function for use in Shiny — grVizOutput","text":"Widget output function use Shiny","code":""},{"path":"/reference/grVizOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Widget output function for use in Shiny — grVizOutput","text":"","code":"grVizOutput(outputId, width = \"100%\", height = \"400px\")"},{"path":"/reference/grVizOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Widget output function for use in Shiny — grVizOutput","text":"outputId Output variable read . width valid CSS unit width number, coerced string px appended. height valid CSS unit height number, coerced string px appended.","code":""},{"path":"/reference/import_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Import a graph from various graph formats — import_graph","title":"Import a graph from various graph formats — import_graph","text":"Import variety graphs different graph formats create graph object.","code":""},{"path":"/reference/import_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Import a graph from various graph formats — import_graph","text":"","code":"import_graph( graph_file, file_type = NULL, edges_extra_attr_names = NULL, edges_extra_attr_coltypes = NULL, graph_name = NULL, attr_theme = \"default\", write_backups = FALSE, display_msgs = FALSE )"},{"path":"/reference/import_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Import a graph from various graph formats — import_graph","text":"graph_file connection graph file. provided path file, read file disk. Files starting http://, https://, ftp://, ftps:// automatically downloaded. file_type type file imported. Options : gml (GML), sif (SIF), edges (.edges file), mtx (MatrixMarket format). supplied, type graph file inferred file extension. edges_extra_attr_names edges files, vector attribute names beyond data columns can provided order appear input data file. edges_extra_attr_coltypes edges files, string column types attribute columns provided edges_extra_attr_names. string representation character represents extra columns data mappings : c -> character, -> integer, n -> number, d -> double, l -> logical, D -> date, T -> date time, t -> time, ? -> guess, _/-, skips column. graph_name optional string labeling graph object. attr_theme theme (.e., collection graph, node, edge global graph attributes) use graph. default theme called default; hierarchical layout themes called lr, tb, rl, bt (operate left--right, top--bottom, right--left, bottom--top); , larger graphs, fdp theme provides force directed layout. set NULL global graph attributes applied graph upon creation. write_backups option write incremental backups changing graph states disk. TRUE, subdirectory within working directory created used store RDS files. default value FALSE one opt use functionality. display_msgs option display messages primarily concerned changes graph selections. default, FALSE.","code":""},{"path":"/reference/import_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Import a graph from various graph formats — import_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/import_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Import a graph from various graph formats — import_graph","text":"","code":"if (FALSE) { # Import a GML graph file gml_graph <- import_graph( system.file( \"extdata/karate.gml\", package = \"DiagrammeR\")) # Get a count of the graph's nodes gml_graph %>% count_nodes() # Get a count of the graph's edges gml_graph %>% count_edges() }"},{"path":"/reference/invert_selection.html","id":null,"dir":"Reference","previous_headings":"","what":"Invert selection of nodes or edges in a graph — invert_selection","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"Modify selection nodes edges within graph object nodes edges previously selected now selected vice versa.","code":""},{"path":"/reference/invert_selection.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"","code":"invert_selection(graph)"},{"path":"/reference/invert_selection.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/invert_selection.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"graph object class dgr_graph.","code":""},{"path":"/reference/invert_selection.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Invert selection of nodes or edges in a graph — invert_selection","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"standard\") # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\") # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Select nodes with ID # values `1` and `3` graph <- graph %>% select_nodes( nodes = c(1, 3)) # Verify that a node # selection has been made graph %>% get_selection() #> [1] 1 3 # Invert the selection graph <- graph %>% invert_selection() # Verify that the node # selection has been changed graph %>% get_selection() #> [1] 2 4"},{"path":"/reference/is_edge_loop.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the edge a loop edge? — is_edge_loop","title":"Is the edge a loop edge? — is_edge_loop","text":"Determines whether edge definition loop edge.","code":""},{"path":"/reference/is_edge_loop.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the edge a loop edge? — is_edge_loop","text":"","code":"is_edge_loop(graph, edge)"},{"path":"/reference/is_edge_loop.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the edge a loop edge? — is_edge_loop","text":"graph graph object class dgr_graph. edge numeric edge ID value.","code":""},{"path":"/reference/is_edge_loop.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the edge a loop edge? — is_edge_loop","text":"logical value.","code":""},{"path":"/reference/is_edge_loop.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the edge a loop edge? — is_edge_loop","text":"","code":"# Create a graph that has multiple # loop edges graph <- create_graph() %>% add_path(n = 4) %>% add_edge( from = 1, to = 1) %>% add_edge( from = 3, to = 3) # Get the graph's internal # edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 1 1 #> 5 5 3 3 # Determine if edge `4` is # a loop edge graph %>% is_edge_loop(edge = 4) #> [1] TRUE # Determine if edge `2` is # a loop edge graph %>% is_edge_loop(edge = 2) #> [1] FALSE"},{"path":"/reference/is_edge_multiple.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the edge a multiple edge? — is_edge_multiple","title":"Is the edge a multiple edge? — is_edge_multiple","text":"Determines whether edge definition multiple edge IDs associated node pair.","code":""},{"path":"/reference/is_edge_multiple.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the edge a multiple edge? — is_edge_multiple","text":"","code":"is_edge_multiple(graph, edge)"},{"path":"/reference/is_edge_multiple.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the edge a multiple edge? — is_edge_multiple","text":"graph graph object class dgr_graph. edge numeric edge ID value.","code":""},{"path":"/reference/is_edge_multiple.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the edge a multiple edge? — is_edge_multiple","text":"logical value.","code":""},{"path":"/reference/is_edge_multiple.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the edge a multiple edge? — is_edge_multiple","text":"","code":"# Create a graph that has multiple # edges across some node pairs graph <- create_graph() %>% add_path(n = 4) %>% add_edge( from = 1, to = 2) %>% add_edge( from = 3, to = 4) # Get the graph's internal # edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 1 2 #> 5 5 3 4 # Determine if edge `1` is # a multiple edge graph %>% is_edge_multiple(edge = 1) #> [1] TRUE # Determine if edge `2` is # a multiple edge graph %>% is_edge_multiple(edge = 2) #> [1] FALSE"},{"path":"/reference/is_edge_mutual.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the edge mutual with another edge? — is_edge_mutual","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"Determines whether edge definition mutual analogue node pair.","code":""},{"path":"/reference/is_edge_mutual.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"","code":"is_edge_mutual(graph, edge)"},{"path":"/reference/is_edge_mutual.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"graph graph object class dgr_graph. edge numeric edge ID value.","code":""},{"path":"/reference/is_edge_mutual.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"logical value.","code":""},{"path":"/reference/is_edge_mutual.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the edge mutual with another edge? — is_edge_mutual","text":"","code":"# Create a graph that has mutual # edges across some node pairs graph <- create_graph() %>% add_path(n = 4) %>% add_edge( from = 4, to = 3) %>% add_edge( from = 2, to = 1) # Get the graph's internal # edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 4 3 #> 5 5 2 1 # Determine if edge `1` has # a mutual edge graph %>% is_edge_mutual(edge = 1) #> [1] TRUE # Determine if edge `2` has # a mutual edge graph %>% is_edge_mutual(edge = 2) #> [1] FALSE"},{"path":"/reference/is_edge_present.html","id":null,"dir":"Reference","previous_headings":"","what":"Determine whether a specified edge is present — is_edge_present","title":"Determine whether a specified edge is present — is_edge_present","text":"graph object class dgr_graph, determine whether edge (defined pair node IDs node label values) present.","code":""},{"path":"/reference/is_edge_present.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Determine whether a specified edge is present — is_edge_present","text":"","code":"is_edge_present(graph, edge = NULL, from = NULL, to = NULL)"},{"path":"/reference/is_edge_present.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Determine whether a specified edge is present — is_edge_present","text":"graph graph object class dgr_graph. edge edge ID value test presence graph. single, numeric value provided values needn't supplied. node ID edge outgoing, , label associated node. undirected graph, value can interchangeable . node ID edge incoming, , label associated node. undirected graph, value can interchangeable .","code":""},{"path":"/reference/is_edge_present.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Determine whether a specified edge is present — is_edge_present","text":"logical value.","code":""},{"path":"/reference/is_edge_present.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Determine whether a specified edge is present — is_edge_present","text":"","code":"# Create a simple graph with # a path of four nodes graph <- create_graph() %>% add_path( n = 4, type = \"path\", label = c(\"one\", \"two\", \"three\", \"four\")) # Find out if edge ID `3` # is present in the graph graph %>% is_edge_present(edge = 3) #> [1] TRUE # Determine if there are any edges # with the definition `1` -> `2` graph %>% is_edge_present( from = 1, to = 2) #> [1] TRUE # Determine if there are any edges # with the definition `4` -> `5` graph %>% is_edge_present( from = 4, to = 5) #> [1] FALSE # Determine whether an edge, # defined by its labels as # `two` -> `three`, exists in # the graph graph %>% is_edge_present( from = \"two\", to = \"three\") #> [1] TRUE # Set the graph as undirected # and determine whether an # edge between nodes with labels # `three` and `two` exists graph %>% set_graph_undirected() %>% is_edge_present( from = \"three\", to = \"two\") #> [1] TRUE"},{"path":"/reference/is_graph_connected.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a connected graph? — is_graph_connected","title":"Is the graph a connected graph? — is_graph_connected","text":"Determines whether graph connected graph.","code":""},{"path":"/reference/is_graph_connected.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a connected graph? — is_graph_connected","text":"","code":"is_graph_connected(graph)"},{"path":"/reference/is_graph_connected.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a connected graph? — is_graph_connected","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_connected.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a connected graph? — is_graph_connected","text":"logical value.","code":""},{"path":"/reference/is_graph_connected.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a connected graph? — is_graph_connected","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function; this # graph is not connected create_graph() %>% add_gnm_graph( n = 15, m = 10, set_seed = 23) %>% is_graph_connected() #> [1] FALSE # Create another random graph; # this graph is connected create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) %>% is_graph_connected() #> [1] TRUE"},{"path":"/reference/is_graph_dag.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a directed acyclic graph? — is_graph_dag","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"Provides logical value whether graph directed acyclic graph (DAG). conditions graph DAG directed graph contain cycles.","code":""},{"path":"/reference/is_graph_dag.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"","code":"is_graph_dag(graph)"},{"path":"/reference/is_graph_dag.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_dag.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"logical value.","code":""},{"path":"/reference/is_graph_dag.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a directed acyclic graph? — is_graph_dag","text":"","code":"# Create a directed graph containing # only a balanced tree graph_tree <- create_graph() %>% add_balanced_tree( k = 2, h = 3) # Determine whether this graph # is a DAG graph_tree %>% is_graph_dag() #> [1] TRUE # Create a directed graph containing # a single cycle graph_cycle <- create_graph() %>% add_cycle(n = 5) # Determine whether this graph # is a DAG graph_cycle %>% is_graph_dag() #> [1] FALSE # Create an undirected graph # containing a balanced tree graph_tree_undirected <- create_graph( directed = FALSE) %>% add_balanced_tree( k = 2, h = 2) # Determine whether this graph # is a DAG graph_tree_undirected %>% is_graph_dag() #> [1] FALSE"},{"path":"/reference/is_graph_directed.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a directed graph? — is_graph_directed","title":"Is the graph a directed graph? — is_graph_directed","text":"Determines whether graph set directed returns logical value effect.","code":""},{"path":"/reference/is_graph_directed.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a directed graph? — is_graph_directed","text":"","code":"is_graph_directed(graph)"},{"path":"/reference/is_graph_directed.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a directed graph? — is_graph_directed","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_directed.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a directed graph? — is_graph_directed","text":"logical value.","code":""},{"path":"/reference/is_graph_directed.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a directed graph? — is_graph_directed","text":"","code":"# Create an empty graph; by default, # new graphs made by `create_graph()` # are directed graph <- create_graph() # Determine whether the graph # is directed graph %>% is_graph_directed() #> [1] TRUE # Use the `set_graph_undirected()` # function and check again whether # the graph is directed graph %>% set_graph_undirected() %>% is_graph_directed() #> [1] FALSE"},{"path":"/reference/is_graph_empty.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph empty? — is_graph_empty","title":"Is the graph empty? — is_graph_empty","text":"Provides logical value whether graph empty (.e., contains nodes).","code":""},{"path":"/reference/is_graph_empty.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph empty? — is_graph_empty","text":"","code":"is_graph_empty(graph)"},{"path":"/reference/is_graph_empty.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph empty? — is_graph_empty","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_empty.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph empty? — is_graph_empty","text":"logical value.","code":""},{"path":"/reference/is_graph_empty.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph empty? — is_graph_empty","text":"","code":"# Create an empty graph graph <- create_graph() # Determine whether the graph is empty graph %>% is_graph_empty() #> [1] TRUE # Create a non-empty graph graph <- create_graph() %>% add_n_nodes(n = 3) # Determine whether this graph is empty graph %>% is_graph_empty() #> [1] FALSE"},{"path":"/reference/is_graph_simple.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a simple graph? — is_graph_simple","title":"Is the graph a simple graph? — is_graph_simple","text":"Determine whether graph simple graph. simple graph one contain loops multiple edges.","code":""},{"path":"/reference/is_graph_simple.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a simple graph? — is_graph_simple","text":"","code":"is_graph_simple(graph)"},{"path":"/reference/is_graph_simple.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a simple graph? — is_graph_simple","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_simple.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a simple graph? — is_graph_simple","text":"logical value.","code":""},{"path":"/reference/is_graph_simple.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a simple graph? — is_graph_simple","text":"","code":"# Create a graph with 2 cycles graph <- create_graph() %>% add_cycle(n = 4) %>% add_cycle(n = 3) # Check if the graph is simple graph %>% is_graph_simple() #> [1] TRUE"},{"path":"/reference/is_graph_undirected.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph an undirected graph? — is_graph_undirected","title":"Is the graph an undirected graph? — is_graph_undirected","text":"Determines whether graph set undirected returns logical value effect.","code":""},{"path":"/reference/is_graph_undirected.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph an undirected graph? — is_graph_undirected","text":"","code":"is_graph_undirected(graph)"},{"path":"/reference/is_graph_undirected.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph an undirected graph? — is_graph_undirected","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_undirected.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph an undirected graph? — is_graph_undirected","text":"logical value.","code":""},{"path":"/reference/is_graph_undirected.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph an undirected graph? — is_graph_undirected","text":"","code":"# Create an empty graph; by # default, new graphs made # by `create_graph()` are # directed graph, so, use # `directed = FALSE` to create # an undirected graph graph <- create_graph( directed = FALSE) # Determine whether the # graph is undirected graph %>% is_graph_undirected() #> [1] TRUE # Use the `set_graph_directed()` # function and check again # as to whether the graph is # undirected graph %>% set_graph_directed() %>% is_graph_undirected() #> [1] FALSE"},{"path":"/reference/is_graph_weighted.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a weighted graph? — is_graph_weighted","title":"Is the graph a weighted graph? — is_graph_weighted","text":"Provides logical value whether graph weighted. graph considered weighted contains edges edge weight attribute numerical values assigned edges.","code":""},{"path":"/reference/is_graph_weighted.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a weighted graph? — is_graph_weighted","text":"","code":"is_graph_weighted(graph)"},{"path":"/reference/is_graph_weighted.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a weighted graph? — is_graph_weighted","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_graph_weighted.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a weighted graph? — is_graph_weighted","text":"logical value.","code":""},{"path":"/reference/is_graph_weighted.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a weighted graph? — is_graph_weighted","text":"","code":"# Create a graph where the edges have # a `weight` attribute graph <- create_graph() %>% add_cycle(n = 5) %>% select_edges() %>% set_edge_attrs_ws( edge_attr = weight, value = c(3, 5, 2, 9, 6)) %>% clear_selection() # Determine whether the graph # is a weighted graph graph %>% is_graph_weighted() #> [1] TRUE # Create graph where the edges do # not have a `weight` attribute graph <- create_graph() %>% add_cycle(n = 5) # Determine whether this graph # is weighted graph %>% is_graph_weighted() #> [1] FALSE"},{"path":"/reference/is_node_present.html","id":null,"dir":"Reference","previous_headings":"","what":"Determine whether a specified node is present — is_node_present","title":"Determine whether a specified node is present — is_node_present","text":"graph object class dgr_graph, determine whether specified node present.","code":""},{"path":"/reference/is_node_present.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Determine whether a specified node is present — is_node_present","text":"","code":"is_node_present(graph, node)"},{"path":"/reference/is_node_present.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Determine whether a specified node is present — is_node_present","text":"graph graph object class dgr_graph. node Either node ID value node label test presence graph.","code":""},{"path":"/reference/is_node_present.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Determine whether a specified node is present — is_node_present","text":"logical value.","code":""},{"path":"/reference/is_node_present.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Determine whether a specified node is present — is_node_present","text":"","code":"# Create a simple graph with # a path of four nodes graph <- create_graph() %>% add_path( n = 4, type = \"path\", label = c( \"one\", \"two\", \"three\", \"four\")) # Determine if there is a node # with ID `1` in the graph graph %>% is_node_present(node = 1) #> [1] TRUE # Determine if there is a node # with ID `5` in the graph graph %>% is_node_present(node = 5) #> [1] FALSE # Determine if there is a node # with label `two` in the graph graph %>% is_node_present(node = \"two\") #> [1] TRUE"},{"path":"/reference/is_property_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Is the graph a property graph? — is_property_graph","title":"Is the graph a property graph? — is_property_graph","text":"Provides logical value whether graph property graph (.e., nodes assigned type value edges assigned rel value).","code":""},{"path":"/reference/is_property_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is the graph a property graph? — is_property_graph","text":"","code":"is_property_graph(graph)"},{"path":"/reference/is_property_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Is the graph a property graph? — is_property_graph","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/is_property_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is the graph a property graph? — is_property_graph","text":"logical value.","code":""},{"path":"/reference/is_property_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is the graph a property graph? — is_property_graph","text":"","code":"# Create a graph with 2 nodes # (with `type` values) and a # single edge (with a `rel`) simple_property_graph <- create_graph() %>% add_node( type = \"a\", label = \"first\") %>% add_node( type = \"b\", label = \"second\") %>% add_edge( from = \"first\", to = \"second\", rel = \"rel_1\") # This is indeed a property graph # but to confirm this, use the # `is_property_graph()` function is_property_graph(simple_property_graph) #> [1] TRUE # If a `type` attribute is # removed, then this graph will # no longer be a property graph simple_property_graph %>% set_node_attrs( node_attr = type, values = NA, nodes = 1) %>% is_property_graph() #> [1] FALSE # An empty graph will return FALSE create_graph() %>% is_property_graph() #> [1] FALSE"},{"path":"/reference/join_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Join new edge attribute values using a data frame — join_edge_attrs","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"Join new edge attribute values left join using data frame. use left join function allows possibility edges graph might removed join.","code":""},{"path":"/reference/join_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"","code":"join_edge_attrs(graph, df, by_graph = NULL, by_df = NULL)"},{"path":"/reference/join_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"graph graph object class dgr_graph. df data frame use joining. by_graph Optional specification column graph's internal edge data frame left join. by_graph by_df provided, natural join occur columns graph's edf df identical names. by_df Optional specification column df left join. by_graph by_df provided, natural join occur columns graph's edf df identical names.","code":""},{"path":"/reference/join_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/join_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Join new edge attribute values using a data frame — join_edge_attrs","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes(n = 5) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\") # Create a data frame with node ID values # representing the graph edges (with `from` and `to` # columns), and, a set of numeric values df <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = rnorm(5, 5)) # Join the values in the data frame to the # graph's edges; this works as a left join using # identically-named columns in the graph and the df # (in this case `from` and `to` are common to both) graph <- graph %>% join_edge_attrs( df = df) # Get the graph's internal edf to show that the # join has been made graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 5.996605 #> 2 2 1 3 6.107490 #> 3 3 2 4 4.721914 #> 4 4 2 5 6.019205 #> 5 5 3 5 5.045437"},{"path":"/reference/join_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Join new node attribute values using a data frame — join_node_attrs","title":"Join new node attribute values using a data frame — join_node_attrs","text":"Join new node attribute values left join using data frame. use left join function allows possibility nodes graph might removed join.","code":""},{"path":"/reference/join_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Join new node attribute values using a data frame — join_node_attrs","text":"","code":"join_node_attrs(graph, df, by_graph = NULL, by_df = NULL)"},{"path":"/reference/join_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Join new node attribute values using a data frame — join_node_attrs","text":"graph graph object class dgr_graph. df data frame use joining. by_graph Optional specification column graph's internal node data frame left join. by_graph by_df provided, natural join occur columns graph's ndf df identical names. by_df Optional specification column df left join. by_graph by_df provided, natural join occur columns graph's ndf df identical names.","code":""},{"path":"/reference/join_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Join new node attribute values using a data frame — join_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/join_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Join new node attribute values using a data frame — join_node_attrs","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes(n = 5) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\") # Create a data frame with node ID values and a # set of numeric values df <- data.frame( values = round(rnorm(6, 5), 2), id = 1:6) # Join the values in the data frame to the # graph's nodes; this works as a left join using # identically-named columns in the graph and the df # (in this case the `id` column is common to both) graph <- graph %>% join_node_attrs( df = df) # Get the graph's internal ndf to show that the # join has been made graph %>% get_node_df() #> id type label values #> 1 1 6.00 #> 2 2 6.11 #> 3 3 4.72 #> 4 4 6.02 #> 5 5 5.05 # Get betweenness values for each node and # add them as a node attribute (Note the # common column name `id` in the different # tables results in a natural join) graph <- graph %>% join_node_attrs( df = get_betweenness(.)) # Get the graph's internal ndf to show that # this join has been made graph %>% get_node_df() #> id type label values betweenness #> 1 1 6.00 0.0 #> 2 2 6.11 1.5 #> 3 3 4.72 0.5 #> 4 4 6.02 0.0 #> 5 5 5.05 0.0"},{"path":"/reference/layout_nodes_w_string.html","id":null,"dir":"Reference","previous_headings":"","what":"Layout nodes using a text-based schematic — layout_nodes_w_string","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"Layout one several groups nodes using text-based schematic. option available apply sorting groups.","code":""},{"path":"/reference/layout_nodes_w_string.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"","code":"layout_nodes_w_string( graph, layout, nodes, sort = NULL, width = 8, height = 8, ll = c(0, 0) )"},{"path":"/reference/layout_nodes_w_string.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"graph graph object class dgr_graph. layout layout character string provides schematic layout. consists rectangular collection - characters (node placement), numbers 1 9 (representing different groupings nodes, described nodes argument). nodes named vector form: c(\"1\" = \"[node_attr]:[value]\", ...). LHS corresponds numbers used layout schematic. RHS provides shorthand node attribute value grouping together nodes (separated colon). instance, \"type:\" RHS (\"1\" LHS) target nodes type attribute equal positioning graph described 1s layout. sort optional sorting method apply collection nodes assigning positional information. Like nodes, named vector form: c(\"1\" = \"[node_attr]:asc|desc\", ...). node_attr case different used nodes. Ideally, node attribute unique values. Choose either asc desc right colon ascending descending sorts. width width layout diagram. height height layout diagram. ll vector describing lower-left coordinates layout","code":""},{"path":"/reference/layout_nodes_w_string.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/layout_nodes_w_string.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Layout nodes using a text-based schematic — layout_nodes_w_string","text":"","code":"# Create a graph with unique labels and # several node `type` groupings graph <- create_graph() %>% add_node(type = \"a\", label = \"a\") %>% add_node(type = \"a\", label = \"b\") %>% add_node(type = \"b\", label = \"c\") %>% add_node(type = \"b\", label = \"d\") %>% add_node(type = \"b\", label = \"e\") %>% add_node(type = \"c\", label = \"f\") %>% add_node(type = \"c\", label = \"g\") # Define a 'layout' for groups of nodes # using a text string (dashes are empty # grid cells, numbers--representing # ad-hoc groupings--correspond to # individual nodes); here, define a layout # with 3 groups of nodes layout <- \" 1-------- 1-------- ---222--- --------3 --------3 \" # Use the `layout` along with what nodes # the numbers correspond to in the graph # with the `nodes` named vectors; the # optional `sort` vector describes how # we should sort the collection of node # before adding position information graph <- graph %>% layout_nodes_w_string( layout = layout, nodes = c(\"1\" = \"type:a\", \"2\" = \"type:b\", \"3\" = \"type:c\"), sort = c(\"1\" = \"label:asc\", \"2\" = \"label:desc\", \"3\" = \"label:desc\")) # Show the graph's node data frame # to confirm that `x` and `y` values # were added to each of the nodes graph %>% get_node_df() #> id type label x y #> 1 1 a a 0 8 #> 2 2 a b 0 6 #> 3 3 b c 5 4 #> 4 4 b d 4 4 #> 5 5 b e 3 4 #> 6 6 c f 8 0 #> 7 7 c g 8 2"},{"path":"/reference/mermaid.html","id":null,"dir":"Reference","previous_headings":"","what":"R + mermaid.js — mermaid","title":"R + mermaid.js — mermaid","text":"Make diagrams R using mermaid.js infrastructure provided htmlwidgets.","code":""},{"path":"/reference/mermaid.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"R + mermaid.js — mermaid","text":"","code":"mermaid(diagram = \"\", ..., width = NULL, height = NULL)"},{"path":"/reference/mermaid.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"R + mermaid.js — mermaid","text":"diagram Diagram mermaid markdown-like language file (connection file name) containing diagram specification. diagram provided diagram = \"\" function assume diagram provided htmltools::tags() DiagrammeR just used dependency injection. ... arguments parameters like send JavaScript. width width resulting graphic pixels. height height resulting graphic pixels.","code":""},{"path":"/reference/mermaid.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"R + mermaid.js — mermaid","text":"object class htmlwidget intelligently print HTML variety contexts including R console, within R Markdown documents, within Shiny output bindings.","code":""},{"path":"/reference/mermaid.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"R + mermaid.js — mermaid","text":"","code":"# Create a simple graph running left to right (note # that the whitespace is not important) # DiagrammeR(\" # graph LR # A-->B # A-->C # C-->E # B-->D # C-->D # D-->F # E-->F # \") # Create the equivalent graph but have it running # from top to bottom # DiagrammeR(\" # graph TB # A-->B # A-->C # C-->E # B-->D # C-->D # D-->F # E-->F # \") # Create a graph with different node shapes and # provide fill styles for each node # DiagrammeR(\"graph LR;A(Rounded)-->B[Squared];B-->C{A Decision}; # C-->D[Square One];C-->E[Square Two]; # style A fill:#E5E25F; style B fill:#87AB51; style C fill:#3C8937; # style D fill:#23772C; style E fill:#B6E6E6;\" # ) # Load in the 'mtcars' dataset # data(mtcars) # connections <- sapply( # 1:ncol(mtcars) # ,function(i) { # paste0( # i # ,\"(\",colnames(mtcars)[i],\")---\" # ,i,\"-stats(\" # ,paste0( # names(summary(mtcars[,i])) # ,\": \" # ,unname(summary(mtcars[,i])) # ,collapse=\"
    \" # ) # ,\")\" # ) # } # ) # Create a diagram using the 'connections' object # DiagrammeR( # paste0( # \"graph TD;\", \"\\n\", # paste(connections, collapse = \"\\n\"),\"\\n\", # \"classDef column fill:#0001CC, stroke:#0D3FF3, stroke-width:1px;\" ,\"\\n\", # \"class \", paste0(1:length(connections), collapse = \",\"), \" column;\" # ) # ) # Also with `DiagrammeR()`, you can use tags # from `htmltools` (just make sure to use # `class = \"mermaid\"`) library(htmltools) # diagramSpec = \" # graph LR; # id1(Start)-->id2(Stop); # style id1 fill:#f9f,stroke:#333,stroke-width:4px; # style id2 fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5; # \" # html_print(tagList( # tags$h1(\"R + mermaid.js = Something Special\") # ,tags$pre(diagramSpec) # ,tags$div(class=\"mermaid\", diagramSpec) # ,DiagrammeR() # )) # Create a sequence diagram # DiagrammeR(\" # sequenceDiagram; # customer->>ticket seller: ask for a ticket; # ticket seller->>database: seats; # alt tickets available # database->>ticket seller: ok; # ticket seller->>customer: confirm; # customer->>ticket seller: ok; # ticket seller->>database: book a seat; # ticket seller->>printer: print a ticket; # else sold out # database->>ticket seller: none left; # ticket seller->>customer: sorry; # end # \")"},{"path":"/reference/mutate_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutate a set of edge attribute values — mutate_edge_attrs","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"Within graph's internal edge data frame (edf), mutate numeric edge attribute values using one expressions.","code":""},{"path":"/reference/mutate_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"","code":"mutate_edge_attrs(graph, ...)"},{"path":"/reference/mutate_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"graph graph object class dgr_graph. ... Expressions used mutation edge attributes. LHS expression either existing new edge attribute name. RHS can consist valid R code uses edge attributes variables. Expressions evaluated order provided, , edge attributes created modified ready use subsequent expressions.","code":""},{"path":"/reference/mutate_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/mutate_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutate a set of edge attribute values — mutate_edge_attrs","text":"","code":"# Create a graph with 3 edges graph <- create_graph() %>% add_path(n = 4) %>% set_edge_attrs( edge_attr = width, values = c(3.4, 2.3, 7.2)) # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel width #> 1 1 1 2 3.4 #> 2 2 2 3 2.3 #> 3 3 3 4 7.2 # Mutate the `width` edge # attribute, dividing each # value by 2 graph <- graph %>% mutate_edge_attrs( width = width / 2) # Get the graph's internal # edf to show that the edge # attribute `width` had its # values changed graph %>% get_edge_df() #> id from to rel width #> 1 1 1 2 1.70 #> 2 2 2 3 1.15 #> 3 3 3 4 3.60 # Create a new edge attribute, # called `length`, that is the # log of values in `width` plus # 2 (and, also, round all values # to 2 decimal places) graph <- graph %>% mutate_edge_attrs( length = (log(width) + 2) %>% round(2)) # Get the graph's internal edf # to show that the edge attribute # values had been mutated graph %>% get_edge_df() #> id from to rel width length #> 1 1 1 2 1.70 2.53 #> 2 2 2 3 1.15 2.14 #> 3 3 3 4 3.60 3.28 # Create a new edge attribute # called `area`, which is the # product of the `width` and # `length` attributes graph <- graph %>% mutate_edge_attrs( area = width * length) # Get the graph's internal edf # to show that the edge attribute # values had been multiplied # together (with new attr `area`) graph %>% get_edge_df() #> id from to rel width length area #> 1 1 1 2 1.70 2.53 4.301 #> 2 2 2 3 1.15 2.14 2.461 #> 3 3 3 4 3.60 3.28 11.808"},{"path":"/reference/mutate_edge_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"Within graph's internal edge data frame (edf), mutate edge attribute values edges selection using one expressions. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/mutate_edge_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"","code":"mutate_edge_attrs_ws(graph, ...)"},{"path":"/reference/mutate_edge_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"graph graph object class dgr_graph. ... Expressions used mutation edge attributes. LHS expression either existing new edge attribute name. RHS can consist valid R code uses edge attributes variables. Expressions evaluated order provided, , edge attributes created modified ready use subsequent expressions.","code":""},{"path":"/reference/mutate_edge_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/mutate_edge_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutate edge attribute values for a selection of edges — mutate_edge_attrs_ws","text":"","code":"# Create a graph with 3 edges # and then select edge `1` graph <- create_graph() %>% add_path(n = 4) %>% set_edge_attrs( edge_attr = width, values = c(3.4, 2.3, 7.2)) %>% select_edges(edges = 1) # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel width #> 1 1 1 2 3.4 #> 2 2 2 3 2.3 #> 3 3 3 4 7.2 # Mutate the `width` edge # attribute for the edges # only in the active selection # of edges (edge `1`); here, # we divide each value in the # selection by 2 graph <- graph %>% mutate_edge_attrs_ws( width = width / 2) # Get the graph's internal # edf to show that the edge # attribute `width` had its # values changed graph %>% get_edge_df() #> id from to rel width #> 1 1 1 2 1.7 #> 2 2 2 3 2.3 #> 3 3 3 4 7.2 # Create a new edge attribute, # called `length`, that is the # log of values in `width` plus # 2 (and, also, round all values # to 2 decimal places) graph <- graph %>% clear_selection() %>% select_edges(edges = 2:3) %>% mutate_edge_attrs_ws( length = (log(width) + 2) %>% round(2)) # Get the graph's internal edf # to show that the edge attribute # values had been mutated only # for edges `2` and `3` (since # edge `1` is excluded, an NA # value is applied) graph %>% get_edge_df() #> id from to rel width length #> 1 1 1 2 1.7 NA #> 2 2 2 3 2.3 2.83 #> 3 3 3 4 7.2 3.97 # Create a new edge attribute # called `area`, which is the # product of the `width` and # `length` attributes graph <- graph %>% mutate_edge_attrs_ws( area = width * length) # Get the graph's internal edf # to show that the edge attribute # values had been multiplied # together (with new attr `area`) # for nodes `2` and `3` graph %>% get_edge_df() #> id from to rel width length area #> 1 1 1 2 1.7 NA NA #> 2 2 2 3 2.3 2.83 6.509 #> 3 3 3 4 7.2 3.97 28.584 # We can invert the selection # and mutate edge `1` several # times to get an `area` value # for that edge graph <- graph %>% invert_selection() %>% mutate_edge_attrs_ws( length = (log(width) + 5) %>% round(2), area = width * length) # Get the graph's internal edf # to show that the 2 mutations # occurred for edge `1`, yielding # non-NA values for its edge # attributes without changing # those of the other edges graph %>% get_edge_df() #> id from to rel width length area #> 1 1 1 2 1.7 5.53 9.401 #> 2 2 2 3 2.3 2.83 6.509 #> 3 3 3 4 7.2 3.97 28.584"},{"path":"/reference/mutate_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutate a set of node attribute values — mutate_node_attrs","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"Within graph's internal node data frame (ndf), mutate numeric node attribute values using one expressions.","code":""},{"path":"/reference/mutate_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"","code":"mutate_node_attrs(graph, ...)"},{"path":"/reference/mutate_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"graph graph object class dgr_graph. ... Expressions used mutation node attributes. LHS expression either existing new node attribute name. RHS can consist valid R code uses node attributes variables. Expressions evaluated order provided, , node attributes created modified ready use subsequent expressions.","code":""},{"path":"/reference/mutate_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/mutate_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutate a set of node attribute values — mutate_node_attrs","text":"","code":"# Create a graph with 3 nodes graph <- create_graph() %>% add_path(n = 3) %>% set_node_attrs( node_attr = width, values = c(1.4, 0.3, 1.1)) # Get the graph's internal ndf # to show which node attributes # are available graph %>% get_node_df() #> id type label width #> 1 1 1 1.4 #> 2 2 2 0.3 #> 3 3 3 1.1 # Mutate the `width` node # attribute, dividing each # value by 2 graph <- graph %>% mutate_node_attrs( width = width / 2) # Get the graph's internal # ndf to show that the node # attribute `width` had its # values changed graph %>% get_node_df() #> id type label width #> 1 1 1 0.70 #> 2 2 2 0.15 #> 3 3 3 0.55 # Create a new node attribute, # called `length`, that is the # log of values in `width` plus # 2 (and, also, round all values # to 2 decimal places) graph <- graph %>% mutate_node_attrs( length = (log(width) + 2) %>% round(2)) # Get the graph's internal ndf # to show that the node attribute # values had been mutated graph %>% get_node_df() #> id type label width length #> 1 1 1 0.70 1.64 #> 2 2 2 0.15 0.10 #> 3 3 3 0.55 1.40 # Create a new node attribute # called `area`, which is the # product of the `width` and # `length` attributes graph <- graph %>% mutate_node_attrs( area = width * length) # Get the graph's internal ndf # to show that the node attribute # values had been multiplied # together (with new attr `area`) graph %>% get_node_df() #> id type label width length area #> 1 1 1 0.70 1.64 1.148 #> 2 2 2 0.15 0.10 0.015 #> 3 3 3 0.55 1.40 0.770"},{"path":"/reference/mutate_node_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"Within graph's internal node data frame (ndf), mutate node attribute values nodes selection using one expressions. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/mutate_node_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"","code":"mutate_node_attrs_ws(graph, ...)"},{"path":"/reference/mutate_node_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"graph graph object class dgr_graph. ... Expressions used mutation node attributes. LHS expression either existing new node attribute name. RHS can consist valid R code uses node attributes variables. Expressions evaluated order provided, , node attributes created modified ready use subsequent expressions.","code":""},{"path":"/reference/mutate_node_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/mutate_node_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Mutate node attribute values for a selection of nodes — mutate_node_attrs_ws","text":"","code":"# Create a graph with 3 nodes # and then select node `1` graph <- create_graph() %>% add_path(n = 3) %>% set_node_attrs( node_attr = width, values = c(1.4, 0.3, 1.1)) %>% select_nodes(nodes = 1) # Get the graph's internal ndf # to show which node attributes # are available graph %>% get_node_df() #> id type label width #> 1 1 1 1.4 #> 2 2 2 0.3 #> 3 3 3 1.1 # Mutate the `width` node # attribute for the nodes # only in the active selection # of nodes (node `1`); here, # we divide each value in the # selection by 2 graph <- graph %>% mutate_node_attrs_ws( width = width / 2) # Get the graph's internal # ndf to show that the node # attribute `width` was # mutated only for node `1` graph %>% get_node_df() #> id type label width #> 1 1 1 0.7 #> 2 2 2 0.3 #> 3 3 3 1.1 # Create a new node attribute, # called `length`, that is the # log of values in `width` plus # 2 (and, also, round all values # to 2 decimal places) graph <- graph %>% clear_selection() %>% select_nodes(nodes = 2:3) %>% mutate_node_attrs_ws( length = (log(width) + 2) %>% round(2)) # Get the graph's internal ndf # to show that the node attribute # values had been mutated only # for nodes `2` and `3` (since # node `1` is excluded, an NA # value is applied) graph %>% get_node_df() #> id type label width length #> 1 1 1 0.7 NA #> 2 2 2 0.3 0.8 #> 3 3 3 1.1 2.1 # Create a new node attribute # called `area`, which is the # product of the `width` and # `length` attributes graph <- graph %>% mutate_node_attrs_ws( area = width * length) # Get the graph's internal ndf # to show that the node attribute # values had been multiplied # together (with new attr `area`) # for nodes `2` and `3` graph %>% get_node_df() #> id type label width length area #> 1 1 1 0.7 NA NA #> 2 2 2 0.3 0.8 0.24 #> 3 3 3 1.1 2.1 2.31 # We can invert the selection # and mutate node `1` several # times to get an `area` value # for that node graph <- graph %>% invert_selection() %>% mutate_node_attrs_ws( length = (log(width) + 5) %>% round(2), area = width * length) # Get the graph's internal ndf # to show that the 2 mutations # occurred for node `1`, yielding # non-NA values for its node # attributes without changing # those of the other nodes graph %>% get_node_df() #> id type label width length area #> 1 1 1 0.7 4.64 3.248 #> 2 2 2 0.3 0.80 0.240 #> 3 3 3 1.1 2.10 2.310"},{"path":"/reference/node_aes.html","id":null,"dir":"Reference","previous_headings":"","what":"Insert node aesthetic attributes during node creation — node_aes","title":"Insert node aesthetic attributes during node creation — node_aes","text":"helper function invoked provide values namesake node_aes argument, present function nodes created.","code":""},{"path":"/reference/node_aes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insert node aesthetic attributes during node creation — node_aes","text":"","code":"node_aes( shape = NULL, style = NULL, penwidth = NULL, color = NULL, fillcolor = NULL, image = NULL, fontname = NULL, fontsize = NULL, fontcolor = NULL, peripheries = NULL, height = NULL, width = NULL, x = NULL, y = NULL, group = NULL, tooltip = NULL, xlabel = NULL, URL = NULL, sides = NULL, orientation = NULL, skew = NULL, distortion = NULL, gradientangle = NULL, fixedsize = NULL, labelloc = NULL, margin = NULL )"},{"path":"/reference/node_aes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insert node aesthetic attributes during node creation — node_aes","text":"shape shape use node. possible shape types include: circle, rectangle, triangle, plaintext, square, polygon. style node line style. style types can used : filled, invisible, diagonals, rounded, dashed, dotted, solid, bold. penwidth thickness stroke line (pt units) node shape. default value 1.0. color color node's outline. Can named colors R knows (obtained using colors() function), , hexadecimal color code. fillcolor color fill shape node. Can named colors R knows (obtained using colors() function), , hexadecimal color code. image reference image location. fontname name system font used node text. fontsize point size font used node text. fontcolor color used node text. Can named colors R knows (obtained using colors() function), , hexadecimal color code. peripheries repeated number node shapes (increasing size) draw node periphery. height height node shape, inches. default value 0.5 whereas minimum value 0.02. understood initial, minimum height node. fixedsize set TRUE, final height node. Otherwise, node label requires height fit, node's height increased contain label. width width node shape, inches. default value 0.5 whereas minimum value 0.02. understood initial, minimum width node. fixedsize set TRUE, final width node. Otherwise, node label requires width fit, node's width increased contain label. x fixed position node x direction. integer-based floating point value accepted. y fixed position node y direction. integer-based floating point value accepted. group node group. tooltip Text node tooltip. xlabel External label node. label placed outside node near . labels added nodes edges placed. labels placed overlap node label. means may possible place . URL URL associate node. Upon rendering plot, clicking nodes associated URLs open URL default browser. sides using shape polygon, value provide number sides polygon. orientation angle, degrees, used rotate nodes shape polygon. polygon shapes (set sides node attribute), value orientation 0 results flat base. skew 0-1 value result node shape skewed right (bottom top). value range 0 -1 skew shape left. distortion distortion factor used shape polygon used. 0-1 value increasingly result top part node polygon shape larger bottom. Moving 0 toward -1 result opposite distortion effect. gradientangle path angle node color fill gradient. fixedsize set FALSE, size node determined smallest width height needed contain label, , margin specified margin node attribute. width height must also least large sizes specified width height node attributes, specify minimum values. set TRUE, node size entirely specified values width height node attributes (.e., node expanded size contain text label). labelloc Sets vertical placement labels nodes clusters. attribute used height node larger height label. labelloc node attribute can set either t (top), c (center), b (bottom). default, label vertically centered. margin Sets amount space around node's label. default, value 0.11,0.055.","code":""},{"path":[]},{"path":"/reference/node_aes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insert node aesthetic attributes during node creation — node_aes","text":"","code":"# Create a new graph and add # a path with several node # aesthetic attributes graph <- create_graph() %>% add_path( n = 3, type = \"path\", node_aes = node_aes( shape = \"circle\", x = c(1, 3, 2), y = c(4, -1, 3) ) ) # View the graph's internal # node data frame; the node # aesthetic attributes have # been inserted graph %>% get_node_df() #> id type label shape x y #> 1 1 path 1 circle 1 4 #> 2 2 path 2 circle 3 -1 #> 3 3 path 3 circle 2 3 # Create a new graph which is # fully connected graph <- create_graph() %>% add_full_graph( n = 4, node_data = node_data(value = 1:4), node_aes = node_aes( x = c(2, 1, 3, 2), y = c(3, 2, 2, 1) ), edge_aes = edge_aes(color = \"blue\") )"},{"path":"/reference/node_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Insert node data attributes during node creation — node_data","title":"Insert node data attributes during node creation — node_data","text":"helper function invoked provide values namesake node_data argument, present function nodes created.","code":""},{"path":"/reference/node_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Insert node data attributes during node creation — node_data","text":"","code":"node_data(...)"},{"path":"/reference/node_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Insert node data attributes during node creation — node_data","text":"... Node data attributes provided one named vectors.","code":""},{"path":[]},{"path":"/reference/node_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Insert node data attributes during node creation — node_data","text":"","code":"# Create a new graph and add # a path with several node # data attributes graph <- create_graph() %>% add_path( n = 3, type = \"path\", node_data = node_data( hour = 5, index = c(1, 3, 2))) # View the graph's internal # node data frame; the node # data attributes have been # inserted graph %>% get_node_df() #> id type label hour index #> 1 1 path 1 5 1 #> 2 2 path 2 5 3 #> 3 3 path 3 5 2"},{"path":"/reference/node_edge_aes_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Options for node and edge aesthetics and data — node_edge_aes_data","title":"Options for node and edge aesthetics and data — node_edge_aes_data","text":"Options node edge aesthetics data","code":""},{"path":"/reference/node_edge_aes_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Options for node and edge aesthetics and data — node_edge_aes_data","text":"node_aes optional list named vectors comprising node aesthetic attributes. helper function node_aes() strongly recommended use contains arguments accepted node aesthetic attributes (e.g., shape, style, color, fillcolor). edge_aes optional list named vectors comprising edge aesthetic attributes. helper function edge_aes() strongly recommended use contains arguments accepted edge aesthetic attributes (e.g., shape, style, penwidth, color). node_data optional list named vectors comprising node data attributes. helper function node_data() strongly recommended use helps bind data specifically created nodes. edge_data optional list named vectors comprising edge data attributes. helper function edge_data() strongly recommended use helps bind data specifically created edges.","code":""},{"path":[]},{"path":"/reference/node_list_1.html","id":null,"dir":"Reference","previous_headings":"","what":"Node list - Version 1. — node_list_1","title":"Node list - Version 1. — node_list_1","text":"simple, 2-column data frame can used generate graph nodes.","code":""},{"path":"/reference/node_list_1.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Node list - Version 1. — node_list_1","text":"","code":"node_list_1"},{"path":"/reference/node_list_1.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Node list - Version 1. — node_list_1","text":"data frame 10 rows 2 variables: id unique, monotonically increasing integer ID value label unique label associated ID value","code":""},{"path":"/reference/node_list_2.html","id":null,"dir":"Reference","previous_headings":"","what":"Node list - Version 2. — node_list_2","title":"Node list - Version 2. — node_list_2","text":"simple, 5-column data frame can used generate graph nodes.","code":""},{"path":"/reference/node_list_2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Node list - Version 2. — node_list_2","text":"","code":"node_list_2"},{"path":"/reference/node_list_2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Node list - Version 2. — node_list_2","text":"data frame 10 rows 5 variables: id unique, monotonically increasing integer ID value label unique label associated ID value type grouping variable either x, y, z value_1 randomized set numeric values 0 10 value_2 randomized set numeric values 0 10","code":""},{"path":"/reference/nudge_node_positions_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Move layout positions of a selection of nodes — nudge_node_positions_ws","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"active selection nodes, move position either x y directions, . Nodes selection position information (.e., NA values x y node attributes) ignored. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/nudge_node_positions_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"","code":"nudge_node_positions_ws(graph, dx, dy)"},{"path":"/reference/nudge_node_positions_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"graph graph object class dgr_graph. dx single numeric value specifying amount selected nodes (non-NA values x y attributes) moved x direction. positive value move nodes right, negative left. dy single numeric value specifying amount selected nodes (non-NA values x y attributes) moved y direction. positive value move nodes , negative .","code":""},{"path":"/reference/nudge_node_positions_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"graph object class dgr_graph.","code":""},{"path":"/reference/nudge_node_positions_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Move layout positions of a selection of nodes — nudge_node_positions_ws","text":"","code":"# Create a simple graph with 4 nodes graph <- create_graph() %>% add_node( type = \"a\", label = \"one\") %>% add_node( type = \"a\", label = \"two\") %>% add_node( type = \"b\", label = \"three\") %>% add_node( type = \"b\", label = \"four\") # Add position information to each of # the graph's nodes graph <- graph %>% set_node_position( node = 1, x = 1, y = 1) %>% set_node_position( node = 2, x = 2, y = 2) %>% set_node_position( node = 3, x = 3, y = 3) %>% set_node_position( node = 4, x = 4, y = 4) # Select all of the graph's nodes using the # `select_nodes()` function (and only # specifying the graph object) graph <- select_nodes(graph) # Move the selected nodes (all the nodes, # in this case) 5 units to the right graph <- graph %>% nudge_node_positions_ws( dx = 5, dy = 0) # View the graph's node data frame graph %>% get_node_df() #> id type label x y #> 1 1 a one 6 1 #> 2 2 a two 7 2 #> 3 3 b three 8 3 #> 4 4 b four 9 4 # Now select nodes that have `type == \"b\"` # and move them in the `y` direction 2 units # (the graph still has an active selection # and so it must be cleared first) graph <- graph %>% clear_selection() %>% select_nodes( conditions = type == \"b\") %>% nudge_node_positions_ws( dx = 0, dy = 2) # View the graph's node data frame graph %>% get_node_df() #> id type label x y #> 1 1 a one 6 1 #> 2 2 a two 7 2 #> 3 3 b three 8 5 #> 4 4 b four 9 6"},{"path":"/reference/open_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Read a graph or graph series from disk — open_graph","title":"Read a graph or graph series from disk — open_graph","text":"Load graph graph series object disk.","code":""},{"path":"/reference/open_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read a graph or graph series from disk — open_graph","text":"","code":"open_graph(file)"},{"path":"/reference/open_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read a graph or graph series from disk — open_graph","text":"file filename graph graph series. Optionally, may contain path file.","code":""},{"path":"/reference/open_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read a graph or graph series from disk — open_graph","text":"","code":"# Create an undirected GNP # graph with 100 nodes using # a probability value of 0.05 gnp_graph <- create_graph( directed = FALSE) %>% add_gnp_graph( n = 100, p = 0.05 ) # Save the graph to disk; use # the file name `gnp_graph.dgr` # save_graph( # x = gnp_graph, # file = \"gnp_graph\" # ) # To read the graph file from # disk, use `open_graph()` # gnp_graph_2 <- # open_graph( # file = \"gnp_graph.dgr\" # )"},{"path":"/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"/reference/pipe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pipe operator — %>%","text":"lhs value magrittr placeholder. rhs function call using magrittr semantics.","code":""},{"path":"/reference/pipe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pipe operator — %>%","text":"result calling rhs(lhs).","code":""},{"path":"/reference/print.dgr_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Print the graph to the terminal — print.dgr_graph","title":"Print the graph to the terminal — print.dgr_graph","text":"function provide summary graph.","code":""},{"path":"/reference/print.dgr_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print the graph to the terminal — print.dgr_graph","text":"","code":"# S3 method for dgr_graph print(x, ...)"},{"path":"/reference/print.dgr_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print the graph to the terminal — print.dgr_graph","text":"x graph object class dgr_graph.","code":""},{"path":"/reference/print.dgr_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Print the graph to the terminal — print.dgr_graph","text":"","code":"if (FALSE) { # Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Get a summary of the graph graph }"},{"path":"/reference/recode_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Recode a set of edge attribute values — recode_edge_attrs","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"Within graph's internal edge data frame (edf), recode character numeric edge attribute values. Optionally, one can specify replacement value unmatched mappings.","code":""},{"path":"/reference/recode_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"","code":"recode_edge_attrs( graph, edge_attr_from, ..., otherwise = NULL, edge_attr_to = NULL )"},{"path":"/reference/recode_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from name edge attribute column values recoded. ... Single-length character vectors recoding instructions. first component value replace second replacement value (form \"[to_replace] -> [replacement]\", ...). otherwise optional single value recoding unmatched values. edge_attr_to optional name new edge attribute recoded values applied. retain original edge attribute values.","code":""},{"path":"/reference/recode_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/recode_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Recode a set of edge attribute values — recode_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 6, set_seed = 23) %>% set_edge_attrs( edge_attr = rel, values = c(\"a\", \"b\", \"a\", \"c\", \"b\", \"d\")) # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel #> 1 1 1 3 a #> 2 2 2 4 b #> 3 3 2 3 a #> 4 4 3 1 c #> 5 5 3 4 b #> 6 6 4 3 d # Recode the `rel` node # attribute, creating a new edge # attribute called `penwidth`; # here, `a` is recoded to `1.0`, # `b` maps to `1.5`, and all # other values become `0.5` graph <- graph %>% recode_edge_attrs( edge_attr_from = rel, \"a -> 1.0\", \"b -> 1.5\", otherwise = 0.5, edge_attr_to = penwidth) # Get the graph's internal edf # to show that the node # attribute values had been # recoded and copied into a # new node attribute graph %>% get_edge_df() #> id from to rel penwidth #> 1 1 1 3 a 1.0 #> 2 2 2 4 b 1.5 #> 3 3 2 3 a 1.0 #> 4 4 3 1 c 0.5 #> 5 5 3 4 b 1.5 #> 6 6 4 3 d 0.5"},{"path":"/reference/recode_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Recode a set of node attribute values — recode_node_attrs","title":"Recode a set of node attribute values — recode_node_attrs","text":"Within graph's internal node data frame (ndf), recode character numeric node attribute values. Optionally, one can specify replacement value unmatched mappings.","code":""},{"path":"/reference/recode_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Recode a set of node attribute values — recode_node_attrs","text":"","code":"recode_node_attrs( graph, node_attr_from, ..., otherwise = NULL, node_attr_to = NULL )"},{"path":"/reference/recode_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Recode a set of node attribute values — recode_node_attrs","text":"graph graph object class dgr_graph. node_attr_from name node attribute column values recoded. ... Single-length character vectors recoding instructions. first component value replace second replacement value (form \"[to_replace] -> [replacement]\", ...). otherwise optional single value recoding unmatched values. node_attr_to optional name new node attribute recoded values applied. retain original node attribute values.","code":""},{"path":"/reference/recode_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Recode a set of node attribute values — recode_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/recode_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Recode a set of node attribute values — recode_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) %>% set_node_attrs( node_attr = shape, values = c(\"circle\", \"hexagon\", \"rectangle\", \"rectangle\", \"circle\")) # Get the graph's internal ndf # to show which node # attributes are available graph %>% get_node_df() #> id type label shape #> 1 1 1 circle #> 2 2 2 hexagon #> 3 3 3 rectangle #> 4 4 4 rectangle #> 5 5 5 circle # Recode the `shape` node # attribute, so that `circle` # is recoded to `square` and that # `rectangle` becomes `triangle` graph <- graph %>% recode_node_attrs( node_attr_from = shape, \"circle -> square\", \"rectangle -> triangle\") # Get the graph's internal # ndf to show that the node # attribute values had been recoded graph %>% get_node_df() #> id type label shape #> 1 1 1 square #> 2 2 2 hexagon #> 3 3 3 triangle #> 4 4 4 triangle #> 5 5 5 square # Create a new node attribute, # called `color`, that is based # on a recoding of `shape`; here, # map the square shape to a `red` # color and map all other shapes # to a `green` color graph <- graph %>% recode_node_attrs( node_attr_from = shape, \"square -> red\", otherwise = \"green\", node_attr_to = color) # Get the graph's internal ndf # to see the change graph %>% get_node_df() #> id type label shape color #> 1 1 1 square red #> 2 2 2 hexagon green #> 3 3 3 triangle green #> 4 4 4 triangle green #> 5 5 5 square red"},{"path":"/reference/remove_graph_from_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Remove a graph from a graph series — remove_graph_from_graph_series","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"Remove single graph object set graph objects contained within graph series object.","code":""},{"path":"/reference/remove_graph_from_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"","code":"remove_graph_from_graph_series(graph_series, index = \"last\")"},{"path":"/reference/remove_graph_from_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"graph_series graph series object graph object removed. index index graph object removed graph series object.","code":""},{"path":"/reference/remove_graph_from_graph_series.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"graph series object type dgr_graph_1D.","code":""},{"path":"/reference/remove_graph_from_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Remove a graph from a graph series — remove_graph_from_graph_series","text":"","code":"# Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # Remove the second graph # from the graph series series <- series %>% remove_graph_from_graph_series( index = 2) # With `get_graph_series_info()`, # we can ensure that a graph # was removed series %>% get_graph_series_info() #> graph name date_time tz nodes edges directed #> 1 1 graph_mkRJxXyq 2023-11-09 02:20:58 UTC 4 3 TRUE #> 2 2 graph_ySz3BP7j 2023-11-09 02:20:59 UTC 6 5 TRUE"},{"path":"/reference/rename_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Rename an edge attribute — rename_edge_attrs","title":"Rename an edge attribute — rename_edge_attrs","text":"Within graph's internal edge data frame (edf), rename existing edge attribute.","code":""},{"path":"/reference/rename_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rename an edge attribute — rename_edge_attrs","text":"","code":"rename_edge_attrs(graph, edge_attr_from, edge_attr_to)"},{"path":"/reference/rename_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rename an edge attribute — rename_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from name edge attribute renamed. edge_attr_to new name edge attribute column identified edge_attr_from.","code":""},{"path":"/reference/rename_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Rename an edge attribute — rename_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rename_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rename an edge attribute — rename_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 8, set_seed = 23) %>% set_edge_attrs( edge_attr = color, values = \"green\") # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel color #> 1 1 1 3 green #> 2 2 2 1 green #> 3 3 2 5 green #> 4 4 2 3 green #> 5 5 3 2 green #> 6 6 3 5 green #> 7 7 3 4 green #> 8 8 5 3 green # Rename the `color` node # attribute as `weight` graph <- graph %>% rename_edge_attrs( edge_attr_from = color, edge_attr_to = labelfontcolor) # Get the graph's internal # edf to show that the edge # attribute had been renamed graph %>% get_edge_df() #> id from to rel labelfontcolor #> 1 1 1 3 green #> 2 2 2 1 green #> 3 3 2 5 green #> 4 4 2 3 green #> 5 5 3 2 green #> 6 6 3 5 green #> 7 7 3 4 green #> 8 8 5 3 green"},{"path":"/reference/rename_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Rename a node attribute — rename_node_attrs","title":"Rename a node attribute — rename_node_attrs","text":"Within graph's internal node data frame (ndf), rename existing node attribute.","code":""},{"path":"/reference/rename_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rename a node attribute — rename_node_attrs","text":"","code":"rename_node_attrs(graph, node_attr_from, node_attr_to)"},{"path":"/reference/rename_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rename a node attribute — rename_node_attrs","text":"graph graph object class dgr_graph. node_attr_from name node attribute renamed. node_attr_to new name node attribute column identified node_attr_from.","code":""},{"path":"/reference/rename_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Rename a node attribute — rename_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rename_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rename a node attribute — rename_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 8, set_seed = 23) %>% set_node_attrs( node_attr = shape, values = \"circle\") %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the graph's internal ndf # to show which node attributes # are available graph %>% get_node_df() #> id type label shape value #> 1 1 1 circle 5.2 #> 2 2 2 circle 5.3 #> 3 3 3 circle 4.4 #> 4 4 4 circle 5.8 #> 5 5 5 circle 5.9 # Rename the `value` node # attribute as `weight` graph <- graph %>% rename_node_attrs( node_attr_from = value, node_attr_to = weight) # Get the graph's internal # ndf to show that the node # attribute had been renamed graph %>% get_node_df() #> id type label shape weight #> 1 1 1 circle 5.2 #> 2 2 2 circle 5.3 #> 3 3 3 circle 4.4 #> 4 4 4 circle 5.8 #> 5 5 5 circle 5.9"},{"path":"/reference/renderDiagrammeR.html","id":null,"dir":"Reference","previous_headings":"","what":"Widget render function for use in Shiny — renderDiagrammeR","title":"Widget render function for use in Shiny — renderDiagrammeR","text":"Widget render function use Shiny","code":""},{"path":"/reference/renderDiagrammeR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Widget render function for use in Shiny — renderDiagrammeR","text":"","code":"renderDiagrammeR(expr, env = parent.frame(), quoted = FALSE)"},{"path":"/reference/renderDiagrammeR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Widget render function for use in Shiny — renderDiagrammeR","text":"expr expression generates DiagrammeR graph env environment evaluate expr. quoted expr quoted expression (quote())? useful want save expression variable.","code":""},{"path":"/reference/renderGrViz.html","id":null,"dir":"Reference","previous_headings":"","what":"Widget render function for use in Shiny — renderGrViz","title":"Widget render function for use in Shiny — renderGrViz","text":"Widget render function use Shiny","code":""},{"path":"/reference/renderGrViz.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Widget render function for use in Shiny — renderGrViz","text":"","code":"renderGrViz(expr, env = parent.frame(), quoted = FALSE)"},{"path":"/reference/renderGrViz.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Widget render function for use in Shiny — renderGrViz","text":"expr expression generates DiagrammeR graph env environment evaluate expr. quoted expr quoted expression (quote())? useful want save expression variable.","code":""},{"path":[]},{"path":"/reference/render_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Render the graph in various formats — render_graph","title":"Render the graph in various formats — render_graph","text":"Using dgr_graph object, render graph RStudio Viewer.","code":""},{"path":"/reference/render_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render the graph in various formats — render_graph","text":"","code":"render_graph( graph, layout = NULL, output = NULL, as_svg = FALSE, title = NULL, width = NULL, height = NULL )"},{"path":"/reference/render_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render the graph in various formats — render_graph","text":"graph graph object class dgr_graph. layout string specifying layout type use node placement rendering. Possible layouts include: nicely, circle, tree, kk, fr. output string specifying output type; graph (default) renders graph using grViz() function visNetwork renders graph using visnetwork() function. as_svg option render graph SVG document. title optional title graph using output = \"graph\". width optional parameter specifying width resulting graphic pixels. height optional parameter specifying height resulting graphic pixels.","code":""},{"path":[]},{"path":"/reference/render_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render the graph in various formats — render_graph","text":"","code":"if (interactive()) { # Render a graph that's a # balanced tree create_graph() %>% add_balanced_tree( k = 2, h = 3) %>% render_graph() # Use the `tree` layout for # better node placement in this # hierarchical graph create_graph() %>% add_balanced_tree( k = 2, h = 3) %>% render_graph(layout = \"tree\") # Plot the same tree graph but # don't show the node ID values create_graph() %>% add_balanced_tree( k = 2, h = 3) %>% set_node_attr_to_display() %>% render_graph(layout = \"tree\") # Create a circle graph create_graph() %>% add_gnm_graph( n = 55, m = 75, set_seed = 23) %>% render_graph( layout = \"circle\") # Render the graph using the # `visNetwork` output option create_graph() %>% add_balanced_tree( k = 2, h = 3) %>% render_graph( output = \"visNetwork\") }"},{"path":"/reference/render_graph_from_graph_series.html","id":null,"dir":"Reference","previous_headings":"","what":"Render a graph available in a series — render_graph_from_graph_series","title":"Render a graph available in a series — render_graph_from_graph_series","text":"Using graph series object type dgr_graph_1D, either render graph Viewer output various formats.","code":""},{"path":"/reference/render_graph_from_graph_series.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render a graph available in a series — render_graph_from_graph_series","text":"","code":"render_graph_from_graph_series( graph_series, graph_no, output = \"graph\", width = NULL, height = NULL )"},{"path":"/reference/render_graph_from_graph_series.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render a graph available in a series — render_graph_from_graph_series","text":"graph_series graph series object type dgr_graph_1D. graph_no index graph graph series. output string specifying output type; graph (default) renders graph using grViz() function visNetwork renders graph using visnetwork() function. width optional parameter specifying width resulting graphic pixels. height optional parameter specifying height resulting graphic pixels.","code":""},{"path":[]},{"path":"/reference/render_graph_from_graph_series.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render a graph available in a series — render_graph_from_graph_series","text":"","code":"if (FALSE) { # Create three graphs graph_1 <- create_graph() %>% add_path(n = 4) graph_2 <- create_graph() %>% add_cycle(n = 5) graph_3 <- create_graph() %>% add_star(n = 6) # Create an empty graph series # and add the graphs series <- create_graph_series() %>% add_graph_to_graph_series( graph = graph_1) %>% add_graph_to_graph_series( graph = graph_2) %>% add_graph_to_graph_series( graph = graph_3) # View the second graph in # the series in the Viewer render_graph_from_graph_series( graph_series = series, graph_no = 2) }"},{"path":"/reference/reorder_graph_actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Reorder the stored series of graph actions — reorder_graph_actions","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"Reorder graph actions stored graph use add_graph_action() function. actions invoked specified order via trigger_graph_actions() function.","code":""},{"path":"/reference/reorder_graph_actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"","code":"reorder_graph_actions(graph, indices)"},{"path":"/reference/reorder_graph_actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"graph graph object class dgr_graph. indices numeric vector provides new ordering graph actions. vector can length number graph actions, , shorter length. latter case, ordering places given items first remaining actions follow.","code":""},{"path":"/reference/reorder_graph_actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"graph object class dgr_graph.","code":""},{"path":"/reference/reorder_graph_actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reorder the stored series of graph actions — reorder_graph_actions","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) # Add three graph actions to the # graph graph <- graph %>% add_graph_action( fcn = \"rescale_node_attrs\", node_attr_from = \"pagerank\", node_attr_to = \"width\", action_name = \"pgrnk_to_width\") %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\", action_name = \"get_pagerank\") %>% add_graph_action( fcn = \"colorize_node_attrs\", node_attr_from = \"width\", node_attr_to = \"fillcolor\", action_name = \"pgrnk_fillcolor\") # View the graph actions for the graph # object by using the function called # `get_graph_actions()` graph %>% get_graph_actions() #> # A tibble: 3 × 3 #> action_index action_name expression #> #> 1 1 pgrnk_to_width rescale_node_attrs(graph = graph, node_attr_from… #> 2 2 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_fcn… #> 3 3 pgrnk_fillcolor colorize_node_attrs(graph = graph, node_attr_fro… # We note that the order isn't # correct and that the `get_pagerank` # action should be the 1st action # and `pgrnk_to_width` should go # in 2nd place; to fix this, use the # function `reorder_graph_actions()` # and specify the reordering with a # numeric vector graph <- graph %>% reorder_graph_actions( indices = c(2, 1, 3)) # View the graph actions for the graph # object once again to verify that # we have the desired order of actions graph %>% get_graph_actions() #> # A tibble: 3 × 3 #> action_index action_name expression #> #> 1 1 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_fcn… #> 2 2 pgrnk_to_width rescale_node_attrs(graph = graph, node_attr_from… #> 3 3 pgrnk_fillcolor colorize_node_attrs(graph = graph, node_attr_fro…"},{"path":"/reference/replace_in_spec.html","id":null,"dir":"Reference","previous_headings":"","what":"Razor-like template for diagram specification — replace_in_spec","title":"Razor-like template for diagram specification — replace_in_spec","text":"Use Razor-like syntax define template use grViz diagram.","code":""},{"path":"/reference/replace_in_spec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Razor-like template for diagram specification — replace_in_spec","text":"","code":"replace_in_spec(spec, envir = parent.frame())"},{"path":"/reference/replace_in_spec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Razor-like template for diagram specification — replace_in_spec","text":"spec String spec parsed evaluated. envir environment substitution functionality takes place.","code":""},{"path":"/reference/replace_in_spec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Razor-like template for diagram specification — replace_in_spec","text":"","code":"if (FALSE) { # a simple example to use a LETTER as a node label spec <- \" digraph { '@1' } [1]: LETTERS[1] \" grViz(replace_in_spec(spec)) spec <- \" digraph a_nice_graph { node [fontname = Helvetica] a [label = '@1'] b [label = '@2-1'] c [label = '@2-2'] d [label = '@2-3'] e [label = '@2-4'] f [label = '@2-5'] g [label = '@2-6'] h [label = '@2-7'] i [label = '@2-8'] j [label = '@2-9'] a -> { b c d e f g h i j} } [1]: 'top' [2]: 10:20 \" grViz(replace_in_spec(spec)) }"},{"path":"/reference/rescale_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Rescale numeric edge attribute values — rescale_edge_attrs","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"graph object class dgr_graph, take set numeric values edge attribute, rescale new numeric color range, write edge attribute new edge attribute column.","code":""},{"path":"/reference/rescale_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"","code":"rescale_edge_attrs( graph, edge_attr_from, to_lower_bound = 0, to_upper_bound = 1, edge_attr_to = NULL, from_lower_bound = NULL, from_upper_bound = NULL )"},{"path":"/reference/rescale_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"graph graph object class dgr_graph. edge_attr_from edge attribute containing numeric data rescaled new numeric color values. to_lower_bound lower bound value set rescaled values. can numeric value X11 color name. to_upper_bound upper bound value set rescaled values. can numeric value X11 color name. edge_attr_to optional name new edge attribute recoded values applied. retain original edge attribute values. from_lower_bound optional, manually set lower bound value rescaled values. set, minimum value set used. from_upper_bound optional, manually set upper bound value rescaled values. set, minimum value set used.","code":""},{"path":"/reference/rescale_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rescale_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rescale numeric edge attribute values — rescale_edge_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 7, set_seed = 23) %>% set_edge_attrs( edge_attr = weight, values = rnorm( n = count_edges(.), mean = 5, sd = 1)) # Get the graph's internal edf # to show which edge attributes # are available graph %>% get_edge_df() #> id from to rel weight #> 1 1 2 8 5.045437 #> 2 2 4 2 6.575780 #> 3 3 4 6 5.218288 #> 4 4 4 9 3.953465 #> 5 5 6 5 4.711311 #> 6 6 6 10 5.481550 #> 7 7 10 9 3.783624 # Rescale the `weight` edge # attribute, so that its values # are rescaled between 0 and 1 graph <- graph %>% rescale_edge_attrs( edge_attr_from = weight, to_lower_bound = 0, to_upper_bound = 1) # Get the graph's internal edf # to show that the edge attribute # values had been rescaled graph %>% get_edge_df() #> id from to rel weight #> 1 1 2 8 0.452 #> 2 2 4 2 1.000 #> 3 3 4 6 0.514 #> 4 4 4 9 0.061 #> 5 5 6 5 0.332 #> 6 6 6 10 0.608 #> 7 7 10 9 0.000 # Scale the values in the `weight` # edge attribute to different # shades of gray for the `color` # edge attribute and different # numerical values for the # `penwidth` attribute graph <- graph %>% rescale_edge_attrs( edge_attr_from = weight, to_lower_bound = \"gray80\", to_upper_bound = \"gray20\", edge_attr_to = color) %>% rescale_edge_attrs( edge_attr_from = weight, to_lower_bound = 0.5, to_upper_bound = 3, edge_attr_to = penwidth) # Get the graph's internal edf # once more to show that scaled # grayscale colors are now available # in `color` and scaled numerical # values are in the `penwidth` # edge attribute graph %>% get_edge_df() #> id from to rel weight color penwidth #> 1 1 2 8 0.452 #838383 1.630 #> 2 2 4 2 1.000 #333333 3.000 #> 3 3 4 6 0.514 #797979 1.785 #> 4 4 4 9 0.061 #C2C2C2 0.652 #> 5 5 6 5 0.332 #959595 1.330 #> 6 6 6 10 0.608 #6B6B6B 2.020 #> 7 7 10 9 0.000 #CCCCCC 0.500"},{"path":"/reference/rescale_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Rescale numeric node attribute values — rescale_node_attrs","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"graph object class dgr_graph, take set numeric values node attribute, rescale new numeric color range, write node attribute new node attribute column.","code":""},{"path":"/reference/rescale_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"","code":"rescale_node_attrs( graph, node_attr_from, to_lower_bound = 0, to_upper_bound = 1, node_attr_to = NULL, from_lower_bound = NULL, from_upper_bound = NULL )"},{"path":"/reference/rescale_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"graph graph object class dgr_graph. node_attr_from node attribute containing numeric data rescaled new numeric color values. to_lower_bound lower bound value set rescaled values. can numeric value X11 color name. to_upper_bound upper bound value set rescaled values. can numeric value X11 color name. node_attr_to optional name new node attribute recoded values applied. retain original node attribute values. from_lower_bound optional, manually set lower bound value rescaled values. set, minimum value set used. from_upper_bound optional, manually set upper bound value rescaled values. set, minimum value set used.","code":""},{"path":"/reference/rescale_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rescale_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Rescale numeric node attribute values — rescale_node_attrs","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the graph's internal ndf # to show which node attributes # are available graph %>% get_node_df() #> id type label value #> 1 1 1 5.3 #> 2 2 2 4.4 #> 3 3 3 5.8 #> 4 4 4 5.9 #> 5 5 5 6.2 # Rescale the `value` node # attribute, so that its values # are rescaled between 0 and 1 graph <- graph %>% rescale_node_attrs( node_attr_from = value, to_lower_bound = 0, to_upper_bound = 1) # Get the graph's internal ndf # to show that the node attribute # values had been rescaled graph %>% get_node_df() #> id type label value #> 1 1 1 0.500 #> 2 2 2 0.000 #> 3 3 3 0.778 #> 4 4 4 0.833 #> 5 5 5 1.000 # Scale the values in the `value` # node attribute to different # shades of gray for the `fillcolor` # and `fontcolor` node attributes graph <- graph %>% rescale_node_attrs( node_attr_from = value, to_lower_bound = \"gray80\", to_upper_bound = \"gray20\", node_attr_to = fillcolor) %>% rescale_node_attrs( node_attr_from = value, to_lower_bound = \"gray5\", to_upper_bound = \"gray95\", node_attr_to = fontcolor) # Get the graph's internal ndf # once more to show that scaled # grayscale colors are now available # in the `fillcolor` and `fontcolor` # node attributes graph %>% get_node_df() #> id type label value fillcolor fontcolor #> 1 1 1 0.500 #7B7B7B #767676 #> 2 2 2 0.000 #CCCCCC #0D0D0D #> 3 3 3 0.778 #525252 #B9B9B9 #> 4 4 4 0.833 #4A4A4A #C7C7C7 #> 5 5 5 1.000 #333333 #F2F2F2"},{"path":"/reference/rev_edge_dir.html","id":null,"dir":"Reference","previous_headings":"","what":"Reverse the direction of all edges in a graph — rev_edge_dir","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"Using directed graph input, reverse direction edges graph.","code":""},{"path":"/reference/rev_edge_dir.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"","code":"rev_edge_dir(graph)"},{"path":"/reference/rev_edge_dir.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/rev_edge_dir.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rev_edge_dir.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reverse the direction of all edges in a graph — rev_edge_dir","text":"","code":"# Create a graph with a # directed tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Inspect the graph's edges graph %>% get_edges() #> [1] \"1->2\" \"1->3\" \"2->4\" \"2->5\" \"3->6\" \"3->7\" # Reverse the edge directions # such that edges are directed # toward the root of the tree graph <- graph %>% rev_edge_dir() # Inspect the graph's edges # after their reversal graph %>% get_edges() #> [1] \"2->1\" \"3->1\" \"4->2\" \"5->2\" \"6->3\" \"7->3\""},{"path":"/reference/rev_edge_dir_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"Using directed graph selection edges input, reverse direction selected edges input graph. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/rev_edge_dir_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"","code":"rev_edge_dir_ws(graph)"},{"path":"/reference/rev_edge_dir_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/rev_edge_dir_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/rev_edge_dir_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reverse the direction of selected edges in a graph using an edge selection — rev_edge_dir_ws","text":"","code":"# Create a graph with a # directed tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Inspect the graph's edges graph %>% get_edges() #> [1] \"1->2\" \"1->3\" \"2->4\" \"2->5\" \"3->6\" \"3->7\" # Select all edges associated # with nodes `1` and `2` graph <- graph %>% select_edges_by_node_id( nodes = 1:2) # Reverse the edge directions # of the edges associated with # nodes `1` and `2` graph <- graph %>% rev_edge_dir_ws() # Inspect the graph's edges # after their reversal graph %>% get_edges() #> [1] \"2->1\" \"3->1\" \"4->2\" \"5->2\" \"3->6\" \"3->7\""},{"path":"/reference/save_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Save a graph or graph series to disk — save_graph","title":"Save a graph or graph series to disk — save_graph","text":"Save graph graph series object disk.","code":""},{"path":"/reference/save_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Save a graph or graph series to disk — save_graph","text":"","code":"save_graph(x, file)"},{"path":"/reference/save_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Save a graph or graph series to disk — save_graph","text":"x graph object class dgr_graph graph series object type dgr_graph_1D. file file name graph graph series. Provide character string .dgr extension applied .","code":""},{"path":[]},{"path":"/reference/save_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Save a graph or graph series to disk — save_graph","text":"","code":"# Create an undirected GNP # graph with 100 nodes using # a probability value of 0.05 gnp_graph <- create_graph( directed = FALSE) %>% add_gnp_graph( n = 100, p = 0.05) # Save the graph to disk; use # the file name `gnp_graph.dgr` # save_graph( # x = gnp_graph, # file = \"gnp_graph\" # ) # To read the graph file from # disk, use `open_graph()` # gnp_graph_2 <- # open_graph( # file = \"gnp_graph.dgr\" # )"},{"path":"/reference/select_edges.html","id":null,"dir":"Reference","previous_headings":"","what":"Select edges in a graph — select_edges","title":"Select edges in a graph — select_edges","text":"Select edges graph object class dgr_graph.","code":""},{"path":"/reference/select_edges.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select edges in a graph — select_edges","text":"","code":"select_edges( graph, conditions = NULL, set_op = \"union\", from = NULL, to = NULL, edges = NULL )"},{"path":"/reference/select_edges.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select edges in a graph — select_edges","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval edges. set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists. optional vector node IDs edge outgoing filtering list edges present graph. optional vector node IDs edge incoming filtering list edges present graph. edges optional vector edge IDs filtering list edges present graph.","code":""},{"path":"/reference/select_edges.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select edges in a graph — select_edges","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_edges.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select edges in a graph — select_edges","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"basic\", label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = c(\"a\", \"z\", \"a\"), value = c(6.4, 2.9, 5.0)) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Explicitly select the edge `1`->`4` graph <- graph %>% select_edges( from = 1, to = 4) # Verify that an edge selection has been made # using the `get_selection()` function graph %>% get_selection() #> [1] 1 # Select edges based on the relationship label # being `z` graph <- graph %>% clear_selection() %>% select_edges( conditions = rel == \"z\") # Verify that an edge selection has been made, and # recall that the `2`->`3` edge uniquely has the # `z` relationship label graph %>% get_selection() #> [1] 2 # Select edges based on the edge value attribute # being greater than 3.0 (first clearing the current # selection of edges) graph <- graph %>% clear_selection() %>% select_edges( conditions = value > 3.0) # Verify that the correct edge selection has been # made; in this case, edges `1`->`4` and # `3`->`1` have values for `value` > 3.0 graph %>% get_selection() #> [1] 1 3"},{"path":"/reference/select_edges_by_edge_id.html","id":null,"dir":"Reference","previous_headings":"","what":"Select edges in a graph using edge ID values — select_edges_by_edge_id","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"Select edges graph object class dgr_graph using edge ID values.","code":""},{"path":"/reference/select_edges_by_edge_id.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"","code":"select_edges_by_edge_id(graph, edges, set_op = \"union\")"},{"path":"/reference/select_edges_by_edge_id.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"graph graph object class dgr_graph. edges vector edge IDs selection edges present graph. set_op set operation perform upon consecutive selections graph edges can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_edges_by_edge_id.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_edges_by_edge_id.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select edges in a graph using edge ID values — select_edges_by_edge_id","text":"","code":"# Create a graph with 5 nodes graph <- create_graph() %>% add_path(n = 5) # Create a graph selection by selecting # edges with edge IDs `1` and `2` graph <- graph %>% select_edges_by_edge_id( edges = 1:2) # Get the selection of edges graph %>% get_selection() #> [1] 1 2 # Perform another selection of edges, # with edge IDs `1`, `2`, and `4` graph <- graph %>% clear_selection() %>% select_edges_by_edge_id( edges = c(1, 2, 4)) # Get the selection of edges graph %>% get_selection() #> [1] 1 2 4 # Get the fraction of edges selected # over all the edges in the graph graph %>% { l <- get_selection(.) %>% length(.) e <- count_edges(.) l/e } #> [1] 0.75"},{"path":"/reference/select_edges_by_node_id.html","id":null,"dir":"Reference","previous_headings":"","what":"Select edges in a graph using node ID values — select_edges_by_node_id","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"Select edges graph object class dgr_graph using node ID values. edges associated provided nodes included selection.","code":""},{"path":"/reference/select_edges_by_node_id.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"","code":"select_edges_by_node_id(graph, nodes, set_op = \"union\")"},{"path":"/reference/select_edges_by_node_id.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"graph graph object class dgr_graph. nodes vector node IDs selection edges present graph. set_op set operation perform upon consecutive selections graph edges can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_edges_by_node_id.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_edges_by_node_id.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select edges in a graph using node ID values — select_edges_by_node_id","text":"","code":"# Create a graph with 5 nodes graph <- create_graph() %>% add_path(n = 5) # Create a graph selection by selecting edges # associated with nodes `1` and `2` graph <- graph %>% select_edges_by_node_id( nodes = 1:2) # Get the selection of edges graph %>% get_selection() #> [1] 1 2 # Perform another selection of edges, with nodes # `1`, `2`, and `4` graph <- graph %>% clear_selection() %>% select_edges_by_node_id( nodes = c(1, 2, 4)) # Get the selection of edges graph %>% get_selection() #> [1] 1 2 3 4 # Get a fraction of the edges selected over all # the edges in the graph graph %>% { l <- get_selection(.) %>% length(.) e <- count_edges(.) l/e } #> [1] 1"},{"path":"/reference/select_last_edges_created.html","id":null,"dir":"Reference","previous_headings":"","what":"Select the last set of edges created in a graph — select_last_edges_created","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"Select last edges created graph object class dgr_graph. function ideally used just creating edges selected.","code":""},{"path":"/reference/select_last_edges_created.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"","code":"select_last_edges_created(graph)"},{"path":"/reference/select_last_edges_created.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/select_last_edges_created.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_last_edges_created.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select the last set of edges created in a graph — select_last_edges_created","text":"","code":"# Create a graph and add a cycle and then # a tree in 2 separate function calls graph <- create_graph() %>% add_cycle( n = 3, rel = \"a\") %>% add_balanced_tree( k = 2, h = 2, rel = \"b\") # Select the last edges created (all edges # from the tree) and then set their edge # color to be `red` graph <- graph %>% select_last_edges_created() %>% set_edge_attrs_ws( edge_attr = color, value = \"red\") %>% clear_selection() # Display the graph's internal edge # data frame to verify the change graph %>% get_edge_df() #> id from to rel color #> 1 1 1 2 a #> 2 2 2 3 a #> 3 3 3 1 a #> 4 4 4 5 b red #> 5 5 4 6 b red #> 6 6 5 7 b red #> 7 7 5 8 b red #> 8 8 6 9 b red #> 9 9 6 10 b red"},{"path":"/reference/select_last_nodes_created.html","id":null,"dir":"Reference","previous_headings":"","what":"Select the last set of nodes created in a graph — select_last_nodes_created","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"Select last nodes created graph object class dgr_graph. function ideally used just creating nodes selected.","code":""},{"path":"/reference/select_last_nodes_created.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"","code":"select_last_nodes_created(graph)"},{"path":"/reference/select_last_nodes_created.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/select_last_nodes_created.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_last_nodes_created.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select the last set of nodes created in a graph — select_last_nodes_created","text":"","code":"# Create a graph and add 4 nodes # in 2 separate function calls graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"a_1\", \"a_2\")) %>% add_n_nodes( n = 2, type = \"b\", label = c(\"b_1\", \"b_2\")) # Select the last nodes created (2 nodes # from the last function call) and then # set their color to be `red` graph <- graph %>% select_last_nodes_created() %>% set_node_attrs_ws( node_attr = color, value = \"red\") %>% clear_selection() # Display the graph's internal node # data frame to verify the change graph %>% get_node_df() #> id type label color #> 1 1 a a_1 #> 2 2 a a_2 #> 3 3 b b_1 red #> 4 4 b b_2 red"},{"path":"/reference/select_nodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Select nodes in a graph — select_nodes","title":"Select nodes in a graph — select_nodes","text":"Select nodes graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select nodes in a graph — select_nodes","text":"","code":"select_nodes(graph, conditions = NULL, set_op = \"union\", nodes = NULL)"},{"path":"/reference/select_nodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select nodes in a graph — select_nodes","text":"graph graph object class dgr_graph. conditions option use filtering conditions retrieval nodes. set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists. nodes optional vector node IDs filtering list nodes present graph.","code":""},{"path":"/reference/select_nodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select nodes in a graph — select_nodes","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select nodes in a graph — select_nodes","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = c(\"a\", \"a\", \"z\", \"z\"), label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = c(\"a\", \"z\", \"a\")) # Create a graph with the ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Explicitly select nodes `1` and `3` graph <- graph %>% select_nodes(nodes = c(1, 3)) # Verify that the node selection has been made # using the `get_selection()` function graph %>% get_selection() #> [1] 1 3 # Select nodes based on the node `type` # being `z` graph <- graph %>% clear_selection() %>% select_nodes( conditions = type == \"z\") # Verify that an node selection has been made, and # recall that the `3` and `4` nodes are of the # `z` type graph %>% get_selection() #> [1] 3 4 # Select edges based on the node value attribute # being greater than 3.0 (first clearing the current # selection of nodes) graph <- graph %>% clear_selection() %>% select_nodes( conditions = value > 3.0) # Verify that the correct node selection has been # made; in this case, nodes `1` and `3` have values # for `value` greater than 3.0 graph %>% get_selection() #> [1] 1 3"},{"path":"/reference/select_nodes_by_degree.html","id":null,"dir":"Reference","previous_headings":"","what":"Select nodes in the graph based on their degree values — select_nodes_by_degree","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"Using graph object class dgr_graph, create selection nodes certain degree values.","code":""},{"path":"/reference/select_nodes_by_degree.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"","code":"select_nodes_by_degree(graph, expressions, set_op = \"union\")"},{"path":"/reference/select_nodes_by_degree.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"graph graph object class dgr_graph. expressions One expressions filtering nodes degree values. Use combination degree type (deg total degree, indeg -degree, outdeg -degree) comparison operator values comparison (e.g., use \"deg >= 2\" select nodes degree greater equal 2). set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_nodes_by_degree.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes_by_degree.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select nodes in the graph based on their degree values — select_nodes_by_degree","text":"","code":"# Create a random graph using # the `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 35, m = 125, set_seed = 23) # Report which nodes have a # total degree (in-degree + # out-degree) of exactly 9 graph %>% select_nodes_by_degree( expressions = \"deg == 9\") %>% get_selection() #> [1] 5 10 26 31 # Report which nodes have a # total degree greater than or # equal to 9 graph %>% select_nodes_by_degree( expressions = \"deg >= 9\") %>% get_selection() #> [1] 1 2 4 5 10 12 18 25 26 31 # Combine two calls of # `select_nodes_by_degree()` to # get those nodes with total # degree less than 3 and total # degree greater than 10 (by # default, those `select...()` # functions will `union` the # sets of nodes selected) graph %>% select_nodes_by_degree( expressions = \"deg < 3\") %>% select_nodes_by_degree( expressions = \"deg > 10\") %>% get_selection() #> [1] 1 2 # Combine two calls of # `select_nodes_by_degree()` to # get those nodes with total # degree greater than or equal # to 3 and less than or equal # to 10 (the key here is to # `intersect` the sets of nodes # selected in the second call) graph %>% select_nodes_by_degree( expressions = \"deg >= 3\") %>% select_nodes_by_degree( expressions = \"deg <= 10\", set_op = \"intersect\") %>% get_selection() #> [1] 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 #> [26] 28 29 30 31 32 33 34 35 # Select all nodes with an # in-degree greater than 5, then, # apply a node attribute to those # selected nodes (coloring the # selected nodes red) graph_2 <- graph %>% select_nodes_by_degree( expressions = \"indeg > 5\") %>% set_node_attrs_ws( node_attr = color, value = \"red\") # Get the selection of nodes graph_2 %>% get_selection() #> [1] 1 4 13 25 35"},{"path":"/reference/select_nodes_by_id.html","id":null,"dir":"Reference","previous_headings":"","what":"Select nodes in a graph by their ID values — select_nodes_by_id","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"Select nodes graph object class dgr_graph node ID values. nodes IDs monotonically increasing integer values, numeric ranges can used selection.","code":""},{"path":"/reference/select_nodes_by_id.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"","code":"select_nodes_by_id(graph, nodes, set_op = \"union\")"},{"path":"/reference/select_nodes_by_id.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"graph graph object class dgr_graph. nodes vector node IDs selection nodes present graph. set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_nodes_by_id.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes_by_id.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select nodes in a graph by their ID values — select_nodes_by_id","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df(n = 10) # Create a graph graph <- create_graph( nodes_df = ndf) # Select nodes `1` to `5` and show that # selection of nodes with `get_selection()` graph %>% select_nodes_by_id(nodes = 1:5) %>% get_selection() #> [1] 1 2 3 4 5"},{"path":"/reference/select_nodes_in_neighborhood.html","id":null,"dir":"Reference","previous_headings":"","what":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"Select nodes neighborhood nodes connected specified distance initial node.","code":""},{"path":"/reference/select_nodes_in_neighborhood.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"","code":"select_nodes_in_neighborhood(graph, node, distance, set_op = \"union\")"},{"path":"/reference/select_nodes_in_neighborhood.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"graph graph object class dgr_graph. node node traversal originate. distance maximum number steps node inclusion selection. set_op set operation perform upon consecutive selections graph nodes. can either union (default), intersection selections intersect, , difference previous selection, exists.","code":""},{"path":"/reference/select_nodes_in_neighborhood.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"graph object class dgr_graph.","code":""},{"path":"/reference/select_nodes_in_neighborhood.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select nodes based on a walk distance from a specified node — select_nodes_in_neighborhood","text":"","code":"# Create a graph containing # a balanced tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Create a graph selection by # selecting nodes in the # neighborhood of node `1`, where # the neighborhood is limited by # nodes that are 1 connection # away from node `1` graph <- graph %>% select_nodes_in_neighborhood( node = 1, distance = 1) # Get the selection of nodes graph %>% get_selection() #> [1] 1 2 3 # Perform another selection # of nodes, this time with a # neighborhood spanning 2 nodes # from node `1` graph <- graph %>% clear_selection() %>% select_nodes_in_neighborhood( node = 1, distance = 2) # Get the selection of nodes graph %>% get_selection() #> [1] 1 2 3 4 5 6 7"},{"path":"/reference/set_cache.html","id":null,"dir":"Reference","previous_headings":"","what":"Cache a vector in the graph — set_cache","title":"Cache a vector in the graph — set_cache","text":"Place vector cache graph object class dgr_graph.","code":""},{"path":"/reference/set_cache.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Cache a vector in the graph — set_cache","text":"","code":"set_cache(graph, to_cache, name = NULL, col = NULL)"},{"path":"/reference/set_cache.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Cache a vector in the graph — set_cache","text":"graph graph object class dgr_graph. to_cache vector data frame. data frame supplied single column vector pull must provided col argument. name optional name cached vector. col data frame provided to_cache column name data frame must provided .","code":""},{"path":"/reference/set_cache.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Cache a vector in the graph — set_cache","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_cache.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Cache a vector in the graph — set_cache","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 22, set_seed = 23 ) # Get the closeness values for # all nodes from `1` to `10` and # store in the graph's cache graph <- graph %>% set_cache( name = \"closeness_vector\", to_cache = get_closeness(.), col = \"closeness\" ) # Get the graph's cache graph %>% get_cache(name = \"closeness_vector\") #> [1] 0.07692308 0.08333333 0.07692308 0.06666667 0.05555556 0.06250000 #> [7] 0.06666667 0.05000000 0.06666667 0.04761905 # Get the difference of betweenness # and closeness values for nodes in # the graph and store the vector in # the graph's cache graph <- graph %>% set_cache( name = \"difference\", to_cache = get_betweenness(.)$betweenness - get_closeness(.)$closeness ) # Get the graph's cache graph %>% get_cache(name = \"difference\") #> [1] 9.25641026 28.91666667 19.08974359 2.60000000 0.44444444 17.93750000 #> [7] 11.93333333 -0.05000000 10.26666667 -0.04761905"},{"path":"/reference/set_edge_attr_to_display.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the edge attribute values to be rendered — set_edge_attr_to_display","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"Set edge attribute type display edge text calling render_graph() function. allows display different types edge attribute values per-edge basis. Without setting display attribute, rendering graph default printing text edges. Setting display edge attribute function first time (.e., display column exist graph's internal edge data frame) insert attr value edges specified edges default value (default) remaining edges.","code":""},{"path":"/reference/set_edge_attr_to_display.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"","code":"set_edge_attr_to_display(graph, attr = NULL, edges = NULL, default = \"label\")"},{"path":"/reference/set_edge_attr_to_display.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"graph graph object class dgr_graph. attr name attribute label text edge obtained. set NULL, NA values assigned display column chosen edges. edges length vector containing one several edge ID values (integers) edge attributes set display rendered graph. NULL, edges graph assigned display value given attr. default name attribute set graph edges included edges. value gets used display edge attribute graph's internal edge data frame.","code":""},{"path":"/reference/set_edge_attr_to_display.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_edge_attr_to_display.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the edge attribute values to be rendered — set_edge_attr_to_display","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_edge_attrs( edge_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # For edge ID values of `1`, # `2`, and `3`, choose to display # the edge `value` attribute (for # the other edges, display nothing) graph <- graph %>% set_edge_attr_to_display( edges = 1:3, attr = value, default = NA) # Show the graph's edge data frame; the # `display` edge attribute will show, for # each row, which edge attribute value to # display when the graph is rendered graph %>% get_edge_df() #> id from to rel display value #> 1 1 2 1 value 2.5 #> 2 2 3 1 value 8.2 #> 3 3 3 2 value 4.2 #> 4 4 4 3 2.4 # This function can be called multiple # times on a graph; after the first time # (i.e., creation of the `display` # attribute), the `default` value won't # be used graph %>% set_edge_attr_to_display( edges = 4, attr = to) %>% set_edge_attr_to_display( edges = c(1, 3), attr = id) %>% get_edge_df() #> id from to rel display value #> 1 1 2 1 id 2.5 #> 2 2 3 1 value 8.2 #> 3 3 3 2 id 4.2 #> 4 4 4 3 to 2.4"},{"path":"/reference/set_edge_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Set edge attribute values — set_edge_attrs","title":"Set edge attribute values — set_edge_attrs","text":"graph object class dgr_graph, set edge attribute values one edges.","code":""},{"path":"/reference/set_edge_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set edge attribute values — set_edge_attrs","text":"","code":"set_edge_attrs(graph, edge_attr, values, from = NULL, to = NULL)"},{"path":"/reference/set_edge_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set edge attribute values — set_edge_attrs","text":"graph graph object class dgr_graph. edge_attr name attribute set. values values set chosen attribute chosen edges. optional vector node IDs edge outgoing filtering list nodes outgoing edges graph. optional vector node IDs edge incoming filtering list nodes incoming edges graph.","code":""},{"path":"/reference/set_edge_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set edge attribute values — set_edge_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_edge_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set edge attribute values — set_edge_attrs","text":"","code":"# Create a simple graph ndf <- create_node_df( n = 4, type = \"basic\", label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\") graph <- create_graph( nodes_df = ndf, edges_df = edf) # Set attribute `color = \"green\"` # for edges `1`->`4` and `3`->`1` # in the graph graph <- graph %>% set_edge_attrs( edge_attr = color, values = \"green\", from = c(1, 3), to = c(4, 1)) # Set attribute `color = \"blue\"` # for all edges in the graph graph <- graph %>% set_edge_attrs( edge_attr = color, values = \"blue\") # Set attribute `color = \"pink\"` # for all edges in graph outbound # from node with ID value `1` graph <- graph %>% set_edge_attrs( edge_attr = color, values = \"pink\", from = 1) # Set attribute `color = \"black\"` # for all edges in graph inbound # to node with ID `1` graph <- graph %>% set_edge_attrs( edge_attr = color, values = \"black\", to = 1)"},{"path":"/reference/set_edge_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Set edge attributes with an edge selection — set_edge_attrs_ws","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"graph object class dgr_graph edge data frame, set edge attribute properties one edges. function makes use active selection edges (function ending _ws hints ). Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/set_edge_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"","code":"set_edge_attrs_ws(graph, edge_attr, value)"},{"path":"/reference/set_edge_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"graph graph object class dgr_graph. edge_attr name attribute set. value value set chosen attribute edges current selection.","code":""},{"path":"/reference/set_edge_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_edge_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set edge attributes with an edge selection — set_edge_attrs_ws","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_path(n = 6) # Select specific edges from # the graph and apply the edge # attribute `color = blue` to # those selected edges graph <- graph %>% select_nodes_by_id(nodes = 2:4) %>% trav_out_edge() %>% set_edge_attrs_ws( edge_attr = color, value = \"blue\") # Show the internal edge data # frame to verify that the # edge attribute has been set # for specific edges graph %>% get_edge_df() #> id from to rel color #> 1 1 1 2 #> 2 2 2 3 blue #> 3 3 3 4 blue #> 4 4 4 5 blue #> 5 5 5 6 "},{"path":"/reference/set_graph_directed.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an undirected graph to a directed graph — set_graph_directed","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"Take graph undirected convert directed graph.","code":""},{"path":"/reference/set_graph_directed.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"","code":"set_graph_directed(graph)"},{"path":"/reference/set_graph_directed.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_directed.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_directed.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert an undirected graph to a directed graph — set_graph_directed","text":"","code":"# Create a graph with a # undirected tree graph <- create_graph( directed = FALSE) %>% add_balanced_tree( k = 2, h = 2) # Convert this graph from # undirected to directed graph <- graph %>% set_graph_directed() # Perform a check on whether # graph is directed graph %>% is_graph_directed() #> [1] TRUE"},{"path":"/reference/set_graph_name.html","id":null,"dir":"Reference","previous_headings":"","what":"Set graph name — set_graph_name","title":"Set graph name — set_graph_name","text":"Set name graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_name.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set graph name — set_graph_name","text":"","code":"set_graph_name(graph, name)"},{"path":"/reference/set_graph_name.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set graph name — set_graph_name","text":"graph graph object class dgr_graph. name name set graph.","code":""},{"path":"/reference/set_graph_name.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set graph name — set_graph_name","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_name.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set graph name — set_graph_name","text":"","code":"# Create an empty graph graph <- create_graph() # Provide the new graph with a name graph <- graph %>% set_graph_name( name = \"example_name\")"},{"path":"/reference/set_graph_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Set graph date-time and timezone — set_graph_time","title":"Set graph date-time and timezone — set_graph_time","text":"Set time timezone graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set graph date-time and timezone — set_graph_time","text":"","code":"set_graph_time(graph, time = NULL, tz = NULL)"},{"path":"/reference/set_graph_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set graph date-time and timezone — set_graph_time","text":"graph graph object class dgr_graph. time date-time set graph. tz timezone set graph.","code":""},{"path":"/reference/set_graph_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set graph date-time and timezone — set_graph_time","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_time.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set graph date-time and timezone — set_graph_time","text":"","code":"# Create an empty graph graph <- create_graph() # Provide the new graph with a timestamp (if `tz` # is not supplied, `GMT` is used as the time zone) graph_1 <- graph %>% set_graph_time(time = \"2015-10-25 15:23:00\") # Provide the new graph with a timestamp that is # the current time; the time zone is inferred from # the user's locale graph_2 <- graph %>% set_graph_time() # The time zone can be updated when a timestamp # is present graph_2 <- graph_2 %>% set_graph_time(tz = \"America/Los_Angeles\")"},{"path":"/reference/set_graph_undirected.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a directed graph to an undirected graph — set_graph_undirected","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"Take graph directed convert undirected graph.","code":""},{"path":"/reference/set_graph_undirected.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"","code":"set_graph_undirected(graph)"},{"path":"/reference/set_graph_undirected.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_undirected.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"graph object class dgr_graph.","code":""},{"path":"/reference/set_graph_undirected.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a directed graph to an undirected graph — set_graph_undirected","text":"","code":"# Create a graph with a # directed tree graph <- create_graph() %>% add_balanced_tree( k = 2, h = 2) # Convert this graph from # directed to undirected graph <- graph %>% set_graph_undirected() # Perform a check on whether # graph is directed graph %>% is_graph_directed() #> [1] FALSE"},{"path":"/reference/set_node_attr_to_display.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the node attribute values to be rendered — set_node_attr_to_display","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"Set node attribute type display node text calling render_graph() function. allows display different types node attribute values per-node basis. Without setting display attribute, rendering graph default printing text label attribute nodes. Setting display node attribute function first time (.e., display column exist graph's internal node data frame) insert attr value nodes specified nodes default value (default) remaining nodes.","code":""},{"path":"/reference/set_node_attr_to_display.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"","code":"set_node_attr_to_display(graph, attr = NULL, nodes = NULL, default = \"label\")"},{"path":"/reference/set_node_attr_to_display.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"graph graph object class dgr_graph. attr name attribute label text node obtained. set NULL, NA values assigned display column chosen nodes. nodes length vector containing one several node ID values (integers) node attributes set display rendered graph. NULL, nodes graph assigned display value given attr. default name attribute set graph nodes included nodes. value gets used display node attribute graph's internal node data frame.","code":""},{"path":"/reference/set_node_attr_to_display.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_attr_to_display.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the node attribute values to be rendered — set_node_attr_to_display","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 4, m = 4, set_seed = 23) %>% set_node_attrs( node_attr = value, values = c(2.5, 8.2, 4.2, 2.4)) # For node ID values of `1`, # `2`, and `3`, choose to display # the node `value` attribute (for # the other nodes, display nothing) graph <- graph %>% set_node_attr_to_display( nodes = 1:3, attr = value, default = NA) # Show the graph's node data frame; the # `display` node attribute will show for # each row, which node attribute value to # display when the graph is rendered graph %>% get_node_df() #> id type label display value #> 1 1 1 value 2.5 #> 2 2 2 value 8.2 #> 3 3 3 value 4.2 #> 4 4 4 2.4 # This function can be called multiple # times on a graph; after the first time # (i.e., creation of the `display` # attribute), the `default` value won't # be used graph %>% set_node_attr_to_display( nodes = 4, attr = label) %>% set_node_attr_to_display( nodes = c(1, 3), attr = id) %>% get_node_df() #> id type label display value #> 1 1 1 id 2.5 #> 2 2 2 value 8.2 #> 3 3 3 id 4.2 #> 4 4 4 label 2.4"},{"path":"/reference/set_node_attr_w_fcn.html","id":null,"dir":"Reference","previous_headings":"","what":"Set node attribute values with a graph function — set_node_attr_w_fcn","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"graph object class dgr_graph node data frame, set node attribute properties nodes graph using one several whole-graph functions.","code":""},{"path":"/reference/set_node_attr_w_fcn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"","code":"set_node_attr_w_fcn(graph, node_attr_fcn, ..., column_name = NULL)"},{"path":"/reference/set_node_attr_w_fcn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"graph graph object class dgr_graph. node_attr_fcn name function use creating column node attribute values. Valid functions : get_alpha_centrality(), get_authority_centrality(), get_betweenness(), get_closeness(), get_cmty_edge_btwns(), get_cmty_fast_greedy(), get_cmty_l_eigenvec(), get_cmty_louvain(), get_cmty_walktrap(), get_degree_distribution(), get_degree_histogram(), get_degree_in(), get_degree_out(), get_degree_total(), get_eccentricity(), get_eigen_centrality(), get_pagerank(), get_s_connected_cmpts(), get_w_connected_cmpts(). ... Arguments values pass named function node_attr_fcn, necessary. column_name option supply column name new node attribute column. NULL column name supplied function used along __A suffix.","code":""},{"path":"/reference/set_node_attr_w_fcn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_attr_w_fcn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set node attribute values with a graph function — set_node_attr_w_fcn","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 22, set_seed = 23) %>% set_node_attrs( node_attr = value, values = rnorm( n = count_nodes(.), mean = 5, sd = 1) %>% round(1)) # Get the betweenness values for # each of the graph's nodes as a # node attribute graph_1 <- graph %>% set_node_attr_w_fcn( node_attr_fcn = \"get_betweenness\") # Inspect the graph's internal # node data frame graph_1 %>% get_node_df() #> id type label value betweenness__A #> 1 1 1 4.4 9.333333 #> 2 2 2 4.6 29.000000 #> 3 3 3 5.9 19.166667 #> 4 4 4 6.5 2.666667 #> 5 5 5 4.1 0.500000 #> 6 6 6 3.6 18.000000 #> 7 7 7 5.4 12.000000 #> 8 8 8 5.8 0.000000 #> 9 9 9 4.7 10.333333 #> 10 10 10 5.7 0.000000 # If a specified function takes argument # values, these can be supplied as well graph_2 <- graph %>% set_node_attr_w_fcn( node_attr_fcn = \"get_alpha_centrality\", alpha = 2, exo = 2) # Inspect the graph's internal # node data frame graph_2 %>% get_node_df() #> id type label value alpha_centrality__A #> 1 1 1 4.4 0.0621118 #> 2 2 2 4.6 -0.5341615 #> 3 3 3 5.9 -0.8157350 #> 4 4 4 6.5 -0.6997930 #> 5 5 5 4.1 1.0641822 #> 6 6 6 3.6 -0.8737060 #> 7 7 7 5.4 -0.6832298 #> 8 8 8 5.8 0.9316770 #> 9 9 9 4.7 -0.4679089 #> 10 10 10 5.7 0.3685300 # The new column name can be provided graph_3 <- graph %>% set_node_attr_w_fcn( node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\") # Inspect the graph's internal # node data frame graph_3 %>% get_node_df() #> id type label value pagerank #> 1 1 1 4.4 0.1416 #> 2 2 2 4.6 0.1401 #> 3 3 3 5.9 0.1262 #> 4 4 4 6.5 0.0637 #> 5 5 5 4.1 0.0478 #> 6 6 6 3.6 0.1976 #> 7 7 7 5.4 0.1318 #> 8 8 8 5.8 0.0422 #> 9 9 9 4.7 0.0693 #> 10 10 10 5.7 0.0398 # If `graph_3` is modified by # adding a new node then the column # `pagerank` will have stale data; we # can run the function again and re-use # the existing column name to provide # updated values graph_3 <- graph_3 %>% add_node( from = 1, to = 3) %>% set_node_attr_w_fcn( node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\") # Inspect the graph's internal # node data frame graph_3 %>% get_node_df() #> id type label value pagerank #> 1 1 1 4.4 0.1349 #> 2 2 2 4.6 0.1352 #> 3 3 3 5.9 0.1585 #> 4 4 4 6.5 0.0670 #> 5 5 5 4.1 0.0461 #> 6 6 6 3.6 0.1300 #> 7 7 7 5.4 0.1014 #> 8 8 8 5.8 0.0400 #> 9 9 9 4.7 0.0685 #> 10 10 10 5.7 0.0440 #> 11 11 NA 0.0744"},{"path":"/reference/set_node_attrs.html","id":null,"dir":"Reference","previous_headings":"","what":"Set node attribute values — set_node_attrs","title":"Set node attribute values — set_node_attrs","text":"graph object class dgr_graph, set node attribute values one nodes.","code":""},{"path":"/reference/set_node_attrs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set node attribute values — set_node_attrs","text":"","code":"set_node_attrs(graph, node_attr, values, nodes = NULL)"},{"path":"/reference/set_node_attrs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set node attribute values — set_node_attrs","text":"graph graph object class dgr_graph. node_attr name attribute set. values values set chosen attribute chosen nodes. nodes optional vector node IDs filtering list nodes present graph.","code":""},{"path":"/reference/set_node_attrs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set node attribute values — set_node_attrs","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_attrs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set node attribute values — set_node_attrs","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"basic\", label = TRUE, value = c(3.5, 2.6, 9.4, 2.7)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = \"leading_to\") # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Set attribute `color = \"green\"` for # nodes `1` and `3` using the graph object graph <- graph %>% set_node_attrs( node_attr = color, values = \"green\", nodes = c(1, 3)) # View the graph's node data frame graph %>% get_node_df() #> id type label value color #> 1 1 basic 1 3.5 green #> 2 2 basic 2 2.6 #> 3 3 basic 3 9.4 green #> 4 4 basic 4 2.7 # Set attribute `color = \"blue\"` for # all nodes in the graph graph <- graph %>% set_node_attrs( node_attr = color, values = \"blue\") # Display the graph's ndf graph %>% get_node_df() #> id type label value color #> 1 1 basic 1 3.5 blue #> 2 2 basic 2 2.6 blue #> 3 3 basic 3 9.4 blue #> 4 4 basic 4 2.7 blue"},{"path":"/reference/set_node_attrs_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Set node attributes with a node selection — set_node_attrs_ws","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"graph object class dgr_graph node data frame, set node attribute properties nodes present node selection. function makes use active selection nodes (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/set_node_attrs_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"","code":"set_node_attrs_ws(graph, node_attr, value)"},{"path":"/reference/set_node_attrs_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"graph graph object class dgr_graph. node_attr name attribute set. value value set chosen attribute nodes current selection.","code":""},{"path":"/reference/set_node_attrs_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_attrs_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set node attributes with a node selection — set_node_attrs_ws","text":"","code":"# Create a simple graph graph <- create_graph() %>% add_path(n = 6) # Select specific nodes from the graph and # apply the node attribute `color = blue` to # those selected nodes graph <- graph %>% select_nodes_by_id( nodes = 1:4) %>% trav_out() %>% set_node_attrs_ws( node_attr = color, value = \"blue\") # Show the internal node data frame to verify # that the node attribute has been set for # specific node graph %>% get_node_df() #> id type label color #> 1 1 1 #> 2 2 2 blue #> 3 3 3 blue #> 4 4 4 blue #> 5 5 5 blue #> 6 6 6 "},{"path":"/reference/set_node_position.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply a layout position to a single node — set_node_position","title":"Apply a layout position to a single node — set_node_position","text":"Apply position information single node. done setting x y attrs node id node label supplied node. rendering graph, nodes attribute values set x y fixed positions graph canvas.","code":""},{"path":"/reference/set_node_position.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply a layout position to a single node — set_node_position","text":"","code":"set_node_position(graph, node, x, y, use_labels = FALSE)"},{"path":"/reference/set_node_position.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply a layout position to a single node — set_node_position","text":"graph graph object class dgr_graph. node single-length vector containing either node ID value (integer) node label (character) position information applied. x x coordinate set node. y y coordinate set node. use_labels option use node label value node. Note possible nodes distinct label values set none exist NA value.","code":""},{"path":"/reference/set_node_position.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Apply a layout position to a single node — set_node_position","text":"graph object class dgr_graph.","code":""},{"path":[]},{"path":"/reference/set_node_position.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply a layout position to a single node — set_node_position","text":"","code":"# Create a simple graph with 4 nodes graph <- create_graph() %>% add_node(label = \"one\") %>% add_node(label = \"two\") %>% add_node(label = \"three\") %>% add_node(label = \"four\") # Add position information to each of # the graph's nodes graph <- graph %>% set_node_position( node = 1, x = 1, y = 1) %>% set_node_position( node = 2, x = 2, y = 2) %>% set_node_position( node = 3, x = 3, y = 3) %>% set_node_position( node = 4, x = 4, y = 4) # View the graph's node data frame to # verify that the `x` and `y` node # attributes are available and set to # the values provided graph %>% get_node_df() #> id type label x y #> 1 1 one 1 1 #> 2 2 two 2 2 #> 3 3 three 3 3 #> 4 4 four 4 4 # The same function can modify the data # in the `x` and `y` attributes graph <- graph %>% set_node_position( node = 1, x = 1, y = 4) %>% set_node_position( node = 2, x = 3, y = 3) %>% set_node_position( node = 3, x = 3, y = 2) %>% set_node_position( node = 4, x = 4, y = 1) # View the graph's node data frame graph %>% get_node_df() #> id type label x y #> 1 1 one 1 4 #> 2 2 two 3 3 #> 3 3 three 3 2 #> 4 4 four 4 1 # Position changes can also be made by # supplying a node `label` value (and setting # `use_labels` to TRUE). For this to work, # all `label` values in the graph's ndf must # be unique and non-NA graph <- graph %>% set_node_position( node = \"one\", x = 1, y = 1, use_labels = TRUE) %>% set_node_position( node = \"two\", x = 2, y = 2, use_labels = TRUE) # View the graph's node data frame graph %>% get_node_df() #> id type label x y #> 1 1 one 1 1 #> 2 2 two 2 2 #> 3 3 three 3 2 #> 4 4 four 4 1"},{"path":"/reference/to_igraph.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a DiagrammeR graph to an igraph one — to_igraph","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"Convert DiagrammeR graph igraph graph object.","code":""},{"path":"/reference/to_igraph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"","code":"to_igraph(graph)"},{"path":"/reference/to_igraph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/to_igraph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"igraph object.","code":""},{"path":"/reference/to_igraph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a DiagrammeR graph to an igraph one — to_igraph","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 36, m = 50, set_seed = 23) # Confirm that `graph` is a # DiagrammeR graph by getting # the object's class class(graph) #> [1] \"dgr_graph\" # Convert the DiagrammeR graph # to an igraph object ig_graph <- to_igraph(graph) # Get the class of the converted # graph, just to be certain class(ig_graph) #> [1] \"igraph\" # Get a summary of the igraph # graph object summary(ig_graph) #> IGRAPH 745e524 DN-B 36 50 -- #> + attr: name (v/c), type (v/c), label (v/c), rel (e/c)"},{"path":"/reference/transform_to_complement_graph.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a complement of a graph — transform_to_complement_graph","title":"Create a complement of a graph — transform_to_complement_graph","text":"Create complement graph contains edges present input graph. important nodes edge attributes input graph's edges lost. Node attributes retained, since affected transformation.","code":""},{"path":"/reference/transform_to_complement_graph.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a complement of a graph — transform_to_complement_graph","text":"","code":"transform_to_complement_graph(graph, loops = FALSE)"},{"path":"/reference/transform_to_complement_graph.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a complement of a graph — transform_to_complement_graph","text":"graph graph object class dgr_graph. loops option whether loops generated complement graph.","code":""},{"path":"/reference/transform_to_complement_graph.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a complement of a graph — transform_to_complement_graph","text":"graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_complement_graph.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a complement of a graph — transform_to_complement_graph","text":"","code":"# Create a simple graph # with a single cycle graph <- create_graph() %>% add_cycle(n = 4) # Get the graph's edge # data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 4 1 # Create the complement # of the graph graph_c <- graph %>% transform_to_complement_graph() # Get the edge data frame # for the complement graph graph_c %>% get_edge_df() #> id from to rel #> 1 1 1 4 #> 2 2 1 3 #> 3 3 2 4 #> 4 4 2 1 #> 5 5 3 2 #> 6 6 3 1 #> 7 7 4 3 #> 8 8 4 2 "},{"path":"/reference/transform_to_min_spanning_tree.html","id":null,"dir":"Reference","previous_headings":"","what":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"Get minimum spanning tree subgraph connected graph class dgr_graph.","code":""},{"path":"/reference/transform_to_min_spanning_tree.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"","code":"transform_to_min_spanning_tree(graph)"},{"path":"/reference/transform_to_min_spanning_tree.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_min_spanning_tree.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_min_spanning_tree.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get a minimum spanning tree subgraph — transform_to_min_spanning_tree","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 10, m = 15, set_seed = 23) # Obtain Jaccard similarity # values for each pair of # nodes as a square matrix j_sim_matrix <- graph %>% get_jaccard_similarity() # Create a weighted, undirected # graph from the resultant matrix # (effectively treating that # matrix as an adjacency matrix) graph <- j_sim_matrix %>% from_adj_matrix(weighted = TRUE) # The graph in this case is a fully connected graph # with loops, where jaccard similarity values are # assigned as edge weights (edge attribute `weight`); # The minimum spanning tree for this graph is the # connected subgraph where the edges retained have # the lowest similarity values possible min_spanning_tree_graph <- graph %>% transform_to_min_spanning_tree() %>% copy_edge_attrs( edge_attr_from = weight, edge_attr_to = label) %>% set_edge_attrs( edge_attr = fontname, values = \"Helvetica\") %>% set_edge_attrs( edge_attr = color, values = \"gray85\") %>% rescale_edge_attrs( edge_attr_from = weight, to_lower_bound = 0.5, to_upper_bound = 4.0, edge_attr_to = penwidth)"},{"path":"/reference/transform_to_subgraph_ws.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"Create subgraph based selection nodes edges stored graph object. function makes use active selection nodes edges (function ending _ws hints ). Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections edges can performed using following edge selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections nodes edges can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until(), trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/transform_to_subgraph_ws.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"","code":"transform_to_subgraph_ws(graph)"},{"path":"/reference/transform_to_subgraph_ws.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_subgraph_ws.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"graph object class dgr_graph.","code":""},{"path":"/reference/transform_to_subgraph_ws.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a subgraph using a node or edge selection — transform_to_subgraph_ws","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 6, value = c(3.5, 2.6, 9.4, 2.7, 5.2, 2.1)) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 4, 5, 2, 6, 2), to = c(2, 4, 1, 3, 5, 5, 4)) # Create a graph graph <- create_graph( nodes_df = ndf, edges_df = edf) # Create a selection of nodes, this selects # nodes `1`, `3`, and `5` graph <- graph %>% select_nodes( conditions = value > 3) # Create a subgraph based on the selection subgraph <- graph %>% transform_to_subgraph_ws() # Display the graph's node data frame subgraph %>% get_node_df() #> id type label value #> 1 1 3.5 #> 2 3 9.4 #> 3 5 5.2 # Display the graph's edge data frame subgraph %>% get_edge_df() #> id from to rel #> 1 4 5 3 # Create a selection of edges, this selects # edges `1`, `2` graph <- graph %>% clear_selection() %>% select_edges( edges = c(1,2)) # Create a subgraph based on the selection subgraph <- graph %>% transform_to_subgraph_ws() # Display the graph's node data frame subgraph %>% get_node_df() #> id type label value #> 1 1 3.5 #> 2 2 2.6 #> 3 4 2.7 # Display the graph's edge data frame subgraph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 4 "},{"path":"/reference/trav_both.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"graph object class dgr_graph move one nodes present selection nodes connected edges, replacing current nodes selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_both.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"","code":"trav_both( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\", add_to_selection = FALSE )"},{"path":"/reference/trav_both.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed nodes. values extant nodes traversed replaced. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg node attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median. add_to_selection option either add traversed nodes active selection nodes (TRUE) switch active selection entirely traversed nodes (FALSE, default case).","code":""},{"path":"/reference/trav_both.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_both.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto neighboring nodes — trav_both","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from node `3` # to adjacent nodes with no conditions on # the nodes traversed to graph %>% select_nodes_by_id(nodes = 3) %>% trav_both() %>% get_selection() #> [1] 1 5 # Traverse from node `2` to any adjacent # nodes, filtering to those nodes that have # numeric values less than `8.0` for # the `values` node attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_both( conditions = values < 8.0) %>% get_selection() #> [1] 4 5 # Traverse from node `5` to any adjacent # nodes, filtering to those nodes that # have a `type` attribute of `b` graph %>% select_nodes_by_id(nodes = 5) %>% trav_both( conditions = type == \"b\") %>% get_selection() #> [1] 3 # Traverse from node `2` to any adjacent # nodes, and use multiple conditions for the # traversal graph %>% select_nodes_by_id(nodes = 2) %>% trav_both( conditions = type == \"a\" & values > 8.0) %>% get_selection() #> [1] 1 # Traverse from node `2` to any adjacent # nodes, and use multiple conditions with # a single-length vector graph %>% select_nodes_by_id(nodes = 2) %>% trav_both( conditions = type == \"a\" | values > 8.0) %>% get_selection() #> [1] 1 # Traverse from node `2` to any adjacent # nodes, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_both( conditions = grepl(\"..d\", label)) %>% get_selection() #> [1] 1 5 # Create another simple graph to demonstrate # copying of node attribute values to traversed # nodes graph <- create_graph() %>% add_path(n = 5) %>% select_nodes_by_id(nodes = c(2, 4)) %>% set_node_attrs_ws( node_attr = value, value = 5) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 1 NA #> 2 2 2 5 #> 3 3 3 NA #> 4 4 4 5 #> 5 5 5 NA # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 #> 4 4 4 5 # Perform a traversal from the inner nodes # (`2` and `4`) to their adjacent nodes (`1`, # `3`, and `5`) while also applying the node # attribute `value` to target nodes; node `3` # will obtain a `value` of 10 since a traversal # to `3` will occur from `2` and `4` (and # multiple values passed will be summed) graph <- graph %>% trav_both( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data frame # after this change graph %>% get_node_df() #> id type label value #> 1 1 1 5 #> 2 3 3 10 #> 3 5 5 5 #> 4 2 2 5 #> 5 4 4 5"},{"path":"/reference/trav_both_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"graph object class dgr_graph move adjacent edges selection one selected nodes, thereby creating selection edges. optional filter edge attribute can limit set edges traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection edges selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_both_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"","code":"trav_both_edge( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\" )"},{"path":"/reference/trav_both_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed edges. edge attribute already exists, values merged traversed edges; otherwise, new edge attribute created. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different edge attribute name. attribute name provided copy_attrs_as exist graph's edf, new edge attribute created chosen name. agg node attribute provided copy_attrs_from, aggregation function required since may cases multiple node attribute values passed onto traversed edge(s). pass single value, following aggregation functions can used: sum, min, max, mean, median.","code":""},{"path":"/reference/trav_both_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_both_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent edges — trav_both_edge","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df) # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from nodes to # adjacent edges with no conditions on the # nodes traversed to graph %>% select_nodes_by_id(nodes = 3) %>% trav_both_edge() %>% get_selection() #> [1] 2 5 # Traverse from node `2` to any adjacent # edges, filtering to those edges that have # NA values for the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = is.na(rel)) %>% get_selection() #> [1] 1 # Traverse from node `2` to any adjacent # edges, filtering to those edges that have # numeric values greater than `6.5` for # the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = values > 6.5) %>% get_selection() #> [1] 2 # Traverse from node `5` to any adjacent # edges, filtering to those edges that # have values equal to `C` for the `rel` # edge attribute graph %>% select_nodes_by_id(nodes = 5) %>% trav_both_edge( conditions = rel == \"C\") %>% get_selection() #> [1] 4 # Traverse from node `2` to any adjacent # edges, filtering to those edges that # have values in the set `B` and `C` for # the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = rel %in% c(\"B\", \"C\")) %>% get_selection() #> [1] 3 4 # Traverse from node `2` to any adjacent # edges, and use multiple conditions for the # traversal graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = rel %in% c(\"B\", \"C\") & values > 4.0) %>% get_selection() #> [1] 3 4 # Traverse from node `2` to any adjacent # edges, and use multiple conditions with # a single-length vector graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = rel %in% c(\"B\", \"C\") | values > 4.0) %>% get_selection() #> [1] 1 3 4 # Traverse from node `2` to any adjacent # edges, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_both_edge( conditions = grepl(\"B|C\", rel)) %>% get_selection() #> [1] 3 4 # Create another simple graph to demonstrate # copying of node attribute values to traversed # edges graph <- create_graph() %>% add_path(n = 4) %>% select_nodes_by_id(nodes = 2:3) %>% set_node_attrs_ws( node_attr = value, value = 5) # Show the graph's internal edge data frame graph %>%get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 2 3 #> 3 3 3 4 # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 1 NA #> 2 2 2 5 #> 3 3 3 5 #> 4 4 4 NA # Perform a traversal from the nodes to # the adjacent edges while also applying # the node attribute `value` to the edges (in # this case summing the `value` of 5 from # all contributing nodes adding as an edge # attribute) graph <- graph %>% trav_both_edge( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal edge data frame # after this change graph %>% get_edge_df() #> id from to rel value #> 1 1 1 2 5 #> 2 2 2 3 10 #> 3 3 3 4 5"},{"path":"/reference/trav_in.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"graph object class dgr_graph move along inward edges one nodes present selection connected nodes, replacing current nodes selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_in.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"","code":"trav_in( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\", add_to_selection = FALSE )"},{"path":"/reference/trav_in.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from providing node attribute name copy node attribute values traversed nodes. values extant nodes traversed replaced. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg node attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median. add_to_selection option either add traversed nodes active selection nodes (TRUE) switch active selection entirely traversed nodes (FALSE, default case).","code":""},{"path":"/reference/trav_in.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_in.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent, inward nodes — trav_in","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from node `4` to # inward adjacent edges with no conditions # on the nodes traversed to graph %>% select_nodes_by_id(nodes = 4) %>% trav_in() %>% get_selection() #> [1] 2 # Traverse from node `5` to inbound-facing # nodes, filtering to those nodes that have # numeric values greater than `5.0` for # the `values` node attribute graph %>% select_nodes_by_id(nodes = 4) %>% trav_in( conditions = values > 5.0) %>% get_selection() #> [1] 2 # Traverse from node `5` to any inbound # nodes, filtering to those nodes that # have a `type` attribute of `b` graph %>% select_nodes_by_id(nodes = 5) %>% trav_in( conditions = type == \"b\") %>% get_selection() #> [1] 3 # Traverse from node `5` to any inbound # nodes, filtering to those nodes that # have a degree of `2` graph %>% { node_degrees <- get_node_info(.) %>% dplyr::select(id, deg) join_node_attrs(., node_degrees) } %>% select_nodes_by_id(nodes = 5) %>% trav_in( conditions = deg == 2) %>% get_selection() #> [1] 3 # Traverse from node `5` to any inbound # nodes, and use multiple conditions for the # traversal graph %>% select_nodes_by_id(nodes = 5) %>% trav_in( conditions = type == \"a\" & values > 6.0) %>% get_selection() #> [1] 2 # Traverse from node `5` to any inbound # nodes, and use multiple conditions with # a single-length vector graph %>% select_nodes_by_id(nodes = 5) %>% trav_in( conditions = type == \"b\" | values > 6.0) %>% get_selection() #> [1] 2 3 # Traverse from node `5` to any inbound # nodes, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_in( conditions = grepl(\"^i.*\", label)) %>% get_selection() #> [1] 2 # Create another simple graph to demonstrate # copying of node attribute values to traversed # nodes graph <- create_graph() %>% add_node() %>% select_nodes() %>% add_n_nodes_ws( n = 2, direction = \"from\") %>% clear_selection() %>% select_nodes_by_id(nodes = 2:3) %>% set_node_attrs_ws( node_attr = value, value = 5) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 NA #> 2 2 5 #> 3 3 5 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 1 2 #> 2 2 1 3 # Perform a traversal from the outer nodes # (`2` and `3`) to the central node (`1`) while # also applying the node attribute `value` to # node `1` (summing the `value` of 5 from # both nodes before applying the value to the # target node) graph <- graph %>% trav_in( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data frame # after this change graph %>% get_node_df() #> id type label value #> 1 1 10 #> 2 2 5 #> 3 3 5"},{"path":"/reference/trav_in_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"graph object class dgr_graph move incoming edges selection one selected nodes, thereby creating selection edges. optional filter edge attribute can limit set edges traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection edges selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_in_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"","code":"trav_in_edge( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL )"},{"path":"/reference/trav_in_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed edges. edge attribute already exists, values merged traversed edges; otherwise, new edge attribute created. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different edge attribute name. attribute name provided copy_attrs_as exist graph's edf, new edge attribute created chosen name.","code":""},{"path":"/reference/trav_in_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_in_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent, inward edges — trav_in_edge","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID # values representing the graph edges # (with `from` and `to` columns), and, # a set of numeric values df <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Join the data frame to the graph's # internal edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df) # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from # nodes to inbound edges with no # conditions on the nodes # traversed to graph %>% select_nodes_by_id(nodes = 2) %>% trav_in_edge() %>% get_selection() #> [1] 1 # Traverse from node `2` to any # inbound edges, filtering to # those edges that have NA values # for the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_in_edge( conditions = is.na(rel)) %>% get_selection() #> [1] 1 # Traverse from node `2` to any # inbound edges, filtering to those # edges that do not have NA values # for the `rel` edge attribute # (since there are no allowed # traversals, the selection of node # `2` is retained) graph %>% select_nodes_by_id(nodes = 2) %>% trav_in_edge( conditions = !is.na(rel)) %>% get_selection() #> [1] 2 # Traverse from node `5` to any # inbound edges, filtering to those # edges that have numeric values # greater than `5.5` for the `rel` # edge attribute graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = values > 5.5) %>% get_selection() #> [1] 4 # Traverse from node `5` to any # inbound edges, filtering to those # edges that have values equal to # `D` for the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = rel == \"D\") %>% get_selection() #> [1] 5 # Traverse from node `5` to any # inbound edges, filtering to those # edges that have values in the set # `C` and `D` for the `rel` edge # attribute graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = rel %in% c(\"C\", \"D\")) %>% get_selection() #> [1] 4 5 # Traverse from node `5` to any # inbound edges, and use multiple # conditions for the traversal graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = rel %in% c(\"C\", \"D\") & values > 5.5) %>% get_selection() #> [1] 4 # Traverse from node `5` to any # inbound edges, and use multiple # conditions with a single-length # vector graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = rel %in% c(\"D\", \"E\") | values > 5.5) %>% get_selection() #> [1] 4 5 # Traverse from node `5` to any # inbound edges, and use a regular # expression as a filtering condition graph %>% select_nodes_by_id(nodes = 5) %>% trav_in_edge( conditions = grepl(\"C|D\", rel)) %>% get_selection() #> [1] 4 5 # Show the graph's internal ndf graph %>% get_node_df() #> id type label #> 1 1 a asd #> 2 2 a iekd #> 3 3 b idj #> 4 4 b edl #> 5 5 b ohd # Show the graph's internal edf graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a traversal from all # nodes to their incoming edges and, # while doing so, copy the `label` # node attribute to any of the nodes' # incoming edges graph <- graph %>% select_nodes() %>% trav_in_edge( copy_attrs_from = label) # Show the graph's internal edge # data frame after this change graph %>% get_edge_df() #> id from to rel label values #> 1 1 1 2 iekd 6.00 #> 2 2 1 3 A idj 6.11 #> 3 3 2 4 B edl 4.72 #> 4 4 2 5 C ohd 6.02 #> 5 5 3 5 D ohd 5.05"},{"path":"/reference/trav_in_node.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"graph object class dgr_graph active selection edges move edge direction connected nodes, replacing current edges selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection edges. traversal, depending traversal conditions, either selection nodes selection . Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/trav_in_node.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"","code":"trav_in_node( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\" )"},{"path":"/reference/trav_in_node.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing edge attribute name copy edge attribute values traversed nodes. edge attribute already exists, values merged traversed nodes; otherwise, new node attribute created. copy_attrs_as edge attribute name provided copy_attrs_from, option allow copied attribute values written different node attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg edge attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median.","code":""},{"path":"/reference/trav_in_node.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_in_node.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected edges onto adjacent, inward nodes — trav_in_node","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from the # edge `1`->`3` to the attached node # in the direction of the edge; here, no # conditions are placed on the nodes # traversed to graph %>% select_edges( from = 1, to = 3) %>% trav_in_node() %>% get_selection() #> [1] 3 # Traverse from edges `2`->`5` and # `3`->`5` to the attached node along # the direction of the edge; both # traversals lead to the same node graph %>% select_edges( from = 2, to = 5) %>% select_edges( from = 3, to = 5) %>% trav_in_node() %>% get_selection() #> [1] 5 # Traverse from the edge `1`->`3` # to the attached node where the edge # is incoming, this time filtering # numeric values greater than `5.0` for # the `values` node attribute graph %>% select_edges( from = 1, to = 3) %>% trav_in_node( conditions = values > 5.0) %>% get_selection() #> [1] 3 # Traverse from the edge `1`->`3` # to the attached node where the edge # is incoming, this time filtering # numeric values less than `5.0` for # the `values` node attribute (the # condition is not met so the original # selection of edge `1` -> `3` remains) graph %>% select_edges( from = 1, to = 3) %>% trav_in_node( conditions = values < 5.0) %>% get_selection() #> [1] 2 # Traverse from the edge `1`->`2` to # the node `2` using multiple conditions # with a single-length vector graph %>% select_edges( from = 1, to = 2) %>% trav_in_node( conditions = grepl(\".*d$\", label) | values < 6.0) %>% get_selection() #> [1] 2 # Create another simple graph to demonstrate # copying of edge attribute values to traversed # nodes graph <- create_graph() %>% add_node() %>% select_nodes() %>% add_n_nodes_ws( n = 2, direction = \"to\") %>% clear_selection() %>% select_nodes_by_id(nodes = 2) %>% set_node_attrs_ws( node_attr = value, value = 8) %>% clear_selection() %>% select_edges_by_edge_id(edges = 1) %>% set_edge_attrs_ws( edge_attr = value, value = 5) %>% clear_selection() %>% select_edges_by_edge_id(edges = 2) %>% set_edge_attrs_ws( edge_attr = value, value = 5) %>% clear_selection() %>% select_edges() # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel value #> 1 1 2 1 5 #> 2 2 3 1 5 # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 NA #> 2 2 8 #> 3 3 NA # Perform a traversal from the edges to # the central node (`1`) while also applying # the edge attribute `value` to the node (in # this case summing the `value` of 5 from # both edges before adding as a node attribute) graph <- graph %>% trav_in_node( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data frame # after this change graph %>% get_node_df() #> id type label value #> 1 1 10 #> 2 2 8 #> 3 3 NA"},{"path":"/reference/trav_in_until.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"graph object class dgr_graph, move along inward edges one nodes present selection connected nodes, replacing current nodes selection nodes traversed reaching nodes satisfy one conditions. traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_in_until.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"","code":"trav_in_until( graph, conditions, max_steps = 30, exclude_unmatched = TRUE, add_to_selection = FALSE )"},{"path":"/reference/trav_in_until.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"graph graph object class dgr_graph. conditions option use stopping condition traversal. condition met traversal (.e., node(s) traversed match condition), traversals terminate nodes. Otherwise, traversals continue terminate number steps provided max_steps reached. max_steps maximum number trav_in() steps (.e., node--node traversals inward direction) allow stopping. exclude_unmatched TRUE (default value) nodes satisfying conditions provided conditions ending selection excluded. add_to_selection TRUE every node traversed part final selection nodes. FALSE (default value) nodes finally traversed part final node selection.","code":""},{"path":"/reference/trav_in_until.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_in_until.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse inward node-by-node until stopping conditions are met — trav_in_until","text":"","code":"# Create a path graph and add # values of 1 to 10 across the # nodes from beginning to end; # select the last path node graph <- create_graph() %>% add_path( n = 10, node_data = node_data( value = 1:10)) %>% select_nodes_by_id( nodes = 10) # Traverse inward, node-by-node # until stopping at a node where # the `value` attribute is 1 graph <- graph %>% trav_in_until( conditions = value == 1) # Get the graph's node selection graph %>% get_selection() #> [1] 1 # Create two cycles in a graph and # add values of 1 to 6 to the # first cycle, and values 7 to # 12 in the second; select nodes # `6` and `12` graph <- create_graph() %>% add_cycle( n = 6, node_data = node_data( value = 1:6)) %>% add_cycle( n = 6, node_data = node_data( value = 7:12)) %>% select_nodes_by_id( nodes = c(6, 12)) # Traverse inward, node-by-node # from `6` and `12` until stopping # at the first nodes where the # `value` attribute is 1, 2, or 10; # specify that we should only # keep the finally traversed to # nodes that satisfy the conditions graph <- graph %>% trav_in_until( conditions = value %in% c(1, 2, 10), exclude_unmatched = TRUE) # Get the graph's node selection graph %>% get_selection() #> [1] 2 10"},{"path":"/reference/trav_out.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"graph object class dgr_graph move along outward edges one nodes present selection connected nodes, replacing current nodes selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_out.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"","code":"trav_out( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\", add_to_selection = FALSE )"},{"path":"/reference/trav_out.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed nodes. values extant nodes traversed replaced. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg node attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median. add_to_selection option either add traversed nodes active selection nodes (TRUE) switch active selection entirely traversed nodes (FALSE, default case).","code":""},{"path":"/reference/trav_out.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_out.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent, outward nodes — trav_out","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from node `3` # to outward adjacent nodes with no conditions # on the nodes traversed to graph %>% select_nodes_by_id(nodes = 3) %>% trav_out() %>% get_selection() #> [1] 5 # Traverse from node `1` to outbound # nodes, filtering to those nodes that have # numeric values greater than `7.0` for # the `values` node attribute graph %>% select_nodes_by_id(nodes = 1) %>% trav_out( conditions = values > 7.0) %>% get_selection() #> [1] 2 # Traverse from node `1` to any outbound # nodes, filtering to those nodes that # have a `type` attribute of `b` graph %>% select_nodes_by_id(nodes = 1) %>% trav_out( conditions = type == \"b\") %>% get_selection() #> [1] 3 # Traverse from node `2` to any outbound # nodes, filtering to those nodes that # have a degree of `1` graph %>% { node_degrees <- get_node_info(.) %>% dplyr::select(id, deg) join_node_attrs( graph = ., df = node_degrees) } %>% select_nodes_by_id(nodes = 2) %>% trav_out( conditions = deg == 1) %>% get_selection() #> [1] 4 # Traverse from node `2` to any outbound # nodes, and use multiple conditions for # the traversal graph %>% select_nodes_by_id(nodes = 2) %>% trav_out( conditions = type == \"a\" & values > 8.0) %>% get_selection() #> [1] 2 # Traverse from node `2` to any # outbound nodes, and use multiple # conditions with a single-length vector graph %>% select_nodes_by_id(nodes = 2) %>% trav_out( conditions = type == \"b\" | values > 8.0) %>% get_selection() #> [1] 4 5 # Traverse from node `2` to any outbound # nodes, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_out( conditions = grepl(\"..d\", label)) %>% get_selection() #> [1] 5 # Create another simple graph to demonstrate # copying of node attribute values to traversed # nodes graph <- create_graph() %>% add_node() %>% select_nodes() %>% add_n_nodes_ws( n = 2, direction = \"to\") %>% clear_selection() %>% select_nodes_by_id(nodes = 2:3) %>% set_node_attrs_ws( node_attr = value, value = 5) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 NA #> 2 2 5 #> 3 3 5 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel #> 1 1 2 1 #> 2 2 3 1 # Perform a traversal from the outer nodes # (`2` and `3`) to the central node (`1`) while # also applying the node attribute `value` to # node `1` (summing the `value` of 5 from # both nodes before applying that value to the # target node) graph <- graph %>% trav_out( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data # frame after this change graph %>% get_node_df() #> id type label value #> 1 1 10 #> 2 2 5 #> 3 3 5"},{"path":"/reference/trav_out_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"graph object class dgr_graph move outgoing edges selection one selected nodes, thereby creating selection edges. optional filter edge attribute can limit set edges traversed . traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection edges selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_out_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"","code":"trav_out_edge( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL )"},{"path":"/reference/trav_out_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing node attribute name copy node attribute values traversed edges. edge attribute already exists, values merged traversed edges; otherwise, new edge attribute created. copy_attrs_as node attribute name provided copy_attrs_from, option allow copied attribute values written different edge attribute name. attribute name provided copy_attrs_as exist graph's edf, new edge attribute created chosen name.","code":""},{"path":"/reference/trav_out_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_out_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected nodes onto adjacent, outward edges — trav_out_edge","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) %>% set_node_attrs( node_attr = values, values = c(2.3, 4.7, 9.4, 8.3, 6.3)) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs( df = df) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 2.3 #> 2 2 a iekd 4.7 #> 3 3 b idj 9.4 #> 4 4 b edl 8.3 #> 5 5 b ohd 6.3 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from nodes to # outbound edges with no conditions on the # nodes traversed to graph %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge() %>% get_selection() #> [1] 1 2 # Traverse from node `1` to any outbound # edges, filtering to those edges that have # NA values for the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge( conditions = is.na(rel)) %>% get_selection() #> [1] 1 # Traverse from node `3` to any outbound # edges, filtering to those edges that have # numeric values greater than `5.0` for # the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 3) %>% trav_out_edge( conditions = values > 5.0) %>% get_selection() #> [1] 5 # Traverse from node `1` to any outbound # edges, filtering to those edges that # have values equal to `A` for the `rel` # edge attribute graph %>% select_nodes_by_id(nodes = 1) %>% trav_out_edge( conditions = rel == \"A\") %>% get_selection() #> [1] 2 # Traverse from node `2` to any outbound # edges, filtering to those edges that # have values in the set `B` and `C` for # the `rel` edge attribute graph %>% select_nodes_by_id(nodes = 2) %>% trav_out_edge( conditions = rel %in% c(\"B\", \"C\")) %>% get_selection() #> [1] 3 4 # Traverse from node `2` to any # outbound edges, and use multiple # conditions for the traversal graph %>% select_nodes_by_id(nodes = 2) %>% trav_out_edge( conditions = rel %in% c(\"B\", \"C\") & values >= 5.0) %>% get_selection() #> [1] 4 # Traverse from node `2` to any # outbound edges, and use multiple # conditions graph %>% select_nodes_by_id(nodes = 2) %>% trav_out_edge( conditions = rel %in% c(\"B\", \"C\") | values > 6.0) %>% get_selection() #> [1] 3 4 # Traverse from node `2` to any outbound # edges, and use a regular expression as # a filtering condition graph %>% select_nodes_by_id(nodes = 2) %>% trav_out_edge( conditions = grepl(\"B|C\", rel)) %>% get_selection() #> [1] 3 4 # Perform a traversal from all nodes to # their outgoing edges and, while doing # so, copy the `label` node attribute # to any of the nodes' incoming edges graph <- graph %>% select_nodes() %>% trav_out_edge( copy_attrs_from = label) # Show the graph's internal edge # data frame after this change graph %>% get_edge_df() #> id from to rel label values #> 1 1 1 2 asd 6.00 #> 2 1 2 3 A asd 6.11 #> 3 2 3 4 B iekd 4.72 #> 4 2 4 5 C iekd 6.02 #> 5 3 5 5 D idj 5.05"},{"path":"/reference/trav_out_node.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"graph object class dgr_graph active selection edges move opposite edge direction connected nodes, replacing current edge selection nodes traversed . optional filter node attribute can limit set nodes traversed . traversal function makes use active selection edges. traversal, depending traversal conditions, either selection nodes selection . Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/trav_out_node.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"","code":"trav_out_node( graph, conditions = NULL, copy_attrs_from = NULL, copy_attrs_as = NULL, agg = \"sum\" )"},{"path":"/reference/trav_out_node.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"graph graph object class dgr_graph. conditions option use filtering conditions traversal. copy_attrs_from Providing edge attribute name copy edge attribute values traversed nodes. edge attribute already exists, values merged traversed nodes; otherwise, new node attribute created. copy_attrs_as edge attribute name provided copy_attrs_from, option allow copied attribute values written different node attribute name. attribute name provided copy_attrs_as exist graph's ndf, new node attribute created chosen name. agg edge attribute provided copy_attrs_from, aggregation function required since may cases multiple edge attribute values passed onto traversed node(s). pass single value, following aggregation functions can used: sum, min, max, mean, median.","code":""},{"path":"/reference/trav_out_node.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_out_node.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse from one or more selected edges onto adjacent, outward nodes — trav_out_node","text":"","code":"# Set a seed suppressWarnings(RNGversion(\"3.5.0\")) set.seed(23) # Create a simple graph graph <- create_graph() %>% add_n_nodes( n = 2, type = \"a\", label = c(\"asd\", \"iekd\")) %>% add_n_nodes( n = 3, type = \"b\", label = c(\"idj\", \"edl\", \"ohd\")) %>% add_edges_w_string( edges = \"1->2 1->3 2->4 2->5 3->5\", rel = c(NA, \"A\", \"B\", \"C\", \"D\")) # Create a data frame with node ID values # representing the graph edges (with `from` # and `to` columns), and, a set of numeric values df_edges <- data.frame( from = c(1, 1, 2, 2, 3), to = c(2, 3, 4, 5, 5), values = round(rnorm(5, 5), 2)) # Create a data frame with node ID values # representing the graph nodes (with the `id` # columns), and, a set of numeric values df_nodes <- data.frame( id = 1:5, values = round(rnorm(5, 7), 2)) # Join the data frame to the graph's internal # edge data frame (edf) graph <- graph %>% join_edge_attrs(df = df_edges) %>% join_node_attrs(df = df_nodes) # Show the graph's internal node data frame graph %>% get_node_df() #> id type label values #> 1 1 a asd 8.58 #> 2 2 a iekd 7.22 #> 3 3 b idj 5.95 #> 4 4 b edl 6.71 #> 5 5 b ohd 7.48 # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel values #> 1 1 1 2 6.00 #> 2 2 1 3 A 6.11 #> 3 3 2 4 B 4.72 #> 4 4 2 5 C 6.02 #> 5 5 3 5 D 5.05 # Perform a simple traversal from the # edge `1`->`3` to the attached node # in the direction of the edge; here, no # conditions are placed on the nodes # traversed to graph %>% select_edges( from = 1, to = 3) %>% trav_out_node() %>% get_selection() #> [1] 1 # Traverse from edges `2`->`5` and # `3`->`5` to the attached node along # the direction of the edge; here, the # traversals lead to different nodes graph %>% select_edges( from = 2, to = 5) %>% select_edges( from = 3, to = 5) %>% trav_out_node() %>% get_selection() #> [1] 2 3 # Traverse from the edge `1`->`3` # to the attached node where the edge # is outgoing, this time filtering # numeric values greater than `7.0` for # the `values` node attribute graph %>% select_edges( from = 1, to = 3) %>% trav_out_node( conditions = values > 7.0) %>% get_selection() #> [1] 1 # Traverse from the edge `1`->`3` # to the attached node where the edge # is outgoing, this time filtering # numeric values less than `7.0` for # the `values` node attribute (the # condition is not met so the original # selection of edge `1`->`3` remains) graph %>% select_edges( from = 1, to = 3) %>% trav_out_node( conditions = values < 7.0) %>% get_selection() #> [1] 2 # Traverse from the edge `1`->`2` # to node `2`, using multiple conditions graph %>% select_edges( from = 1, to = 2) %>% trav_out_node( conditions = grepl(\".*d$\", label) | values < 6.0) %>% get_selection() #> [1] 1 # Create another simple graph to demonstrate # copying of edge attribute values to traversed # nodes graph <- create_graph() %>% add_node() %>% select_nodes() %>% add_n_nodes_ws( n = 2, direction = \"from\") %>% clear_selection() %>% select_nodes_by_id(nodes = 2) %>% set_node_attrs_ws( node_attr = value, value = 8) %>% clear_selection() %>% select_edges_by_edge_id(edges = 1) %>% set_edge_attrs_ws( edge_attr = value, value = 5) %>% clear_selection() %>% select_edges_by_edge_id(edges = 2) %>% set_edge_attrs_ws( edge_attr = value, value = 5) %>% clear_selection() %>% select_edges() # Show the graph's internal edge data frame graph %>% get_edge_df() #> id from to rel value #> 1 1 1 2 5 #> 2 2 1 3 5 # Show the graph's internal node data frame graph %>% get_node_df() #> id type label value #> 1 1 NA #> 2 2 8 #> 3 3 NA # Perform a traversal from the edges to # the central node (`1`) while also applying # the edge attribute `value` to the node (in # this case summing the `value` of 5 from # both edges before adding as a node attribute) graph <- graph %>% trav_out_node( copy_attrs_from = value, agg = \"sum\") # Show the graph's internal node data frame # after this change graph %>% get_node_df() #> id type label value #> 1 1 10 #> 2 2 8 #> 3 3 NA"},{"path":"/reference/trav_out_until.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"graph object class dgr_graph, move along outward edges one nodes present selection connected nodes, replacing current nodes selection nodes traversed reaching nodes satisfy one conditions. traversal function makes use active selection nodes. traversal, depending traversal conditions, either selection nodes selection . Selections nodes can performed using following node selection (select_*()) functions: select_nodes(), select_last_nodes_created(), select_nodes_by_degree(), select_nodes_by_id(), select_nodes_in_neighborhood(). Selections nodes can also performed using following traversal (trav_*()) functions: trav_out(), trav_in(), trav_both(), trav_out_node(), trav_in_node(), trav_out_until(), trav_in_until().","code":""},{"path":"/reference/trav_out_until.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"","code":"trav_out_until( graph, conditions, max_steps = 30, exclude_unmatched = TRUE, add_to_selection = FALSE )"},{"path":"/reference/trav_out_until.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"graph graph object class dgr_graph. conditions option use stopping condition traversal. condition met traversal (.e., node(s) traversed match condition), traversals terminate nodes. Otherwise, traversals continue terminate number steps provided max_steps reached. max_steps maximum number trav_out() steps (.e., node--node traversals outward direction) allow stopping. exclude_unmatched TRUE (default value) nodes satisfying conditions provided conditions ending selection excluded. add_to_selection TRUE every node traversed part final selection nodes. FALSE (default value) nodes finally traversed part final node selection.","code":""},{"path":"/reference/trav_out_until.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_out_until.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse outward node-by-node until stopping conditions are met — trav_out_until","text":"","code":"# Create a path graph and add # values of 1 to 10 across the # nodes from beginning to end; # select the first path node graph <- create_graph() %>% add_path( n = 10, node_data = node_data( value = 1:10)) %>% select_nodes_by_id( nodes = 1) # Traverse outward, node-by-node # until stopping at a node where # the `value` attribute is 8 graph <- graph %>% trav_out_until( conditions = value == 8) # Get the graph's node selection graph %>% get_selection() #> [1] 8 # Create two cycles in graph and # add values of 1 to 6 to the # first cycle, and values 7 to # 12 in the second; select nodes # `1` and `7` graph <- create_graph() %>% add_cycle( n = 6, node_data = node_data( value = 1:6)) %>% add_cycle( n = 6, node_data = node_data( value = 7:12)) %>% select_nodes_by_id( nodes = c(1, 7)) # Traverse outward, node-by-node # from `1` and `7` until stopping # at the first nodes where the # `value` attribute is 5, 6, or 15; # specify that we should only # keep the finally traversed to # nodes that satisfy the conditions graph <- graph %>% trav_out_until( conditions = value %in% c(5, 6, 9), exclude_unmatched = TRUE) # Get the graph's node selection graph %>% get_selection() #> [1] 5 9"},{"path":"/reference/trav_reverse_edge.html","id":null,"dir":"Reference","previous_headings":"","what":"Traverse to any reverse edges — trav_reverse_edge","title":"Traverse to any reverse edges — trav_reverse_edge","text":"active selection edges graph object class dgr_graph, traverse available reverse edges nodes common selected edges. instance, active selection edge 1->2 also (selected) edge 2->1, function can either switch selection 2->1, , incorporate edges active selection edges. traversal function makes use active selection edges. traversal, depending traversal conditions, either selection edges selection . Selections edges can performed using following selection (select_*()) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), select_edges_by_node_id(). Selections edges can also performed using following traversal (trav_*()) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), trav_reverse_edge().","code":""},{"path":"/reference/trav_reverse_edge.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Traverse to any reverse edges — trav_reverse_edge","text":"","code":"trav_reverse_edge(graph, add_to_selection = FALSE)"},{"path":"/reference/trav_reverse_edge.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Traverse to any reverse edges — trav_reverse_edge","text":"graph graph object class dgr_graph. add_to_selection option either add reverse edges active selection edges (TRUE) switch active selection entirely reverse edges (FALSE, default case).","code":""},{"path":"/reference/trav_reverse_edge.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Traverse to any reverse edges — trav_reverse_edge","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trav_reverse_edge.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Traverse to any reverse edges — trav_reverse_edge","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 4, type = \"basic\", label = TRUE) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 4, 2, 3, 3), to = c(4, 1, 3, 2, 1)) # Create a graph with the # ndf and edf graph <- create_graph( nodes_df = ndf, edges_df = edf) # Explicitly select the edges # `1`->`4` and `2`->`3` graph <- graph %>% select_edges( from = 1, to = 4) %>% select_edges( from = 2, to = 3) # Get the inital edge selection graph %>% get_selection() #> [1] 1 3 # Traverse to the reverse edges # (edges `2`: `4`->`1` and # `4`:`3`->`2`) graph <- graph %>% trav_reverse_edge() # Get the current selection of edges graph %>% get_selection() #> [1] 2 4"},{"path":"/reference/trigger_graph_actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Trigger the execution of a series of graph actions — trigger_graph_actions","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"Execute graph actions stored graph use add_graph_action() function. actions invoked order errors encountered trigger warning message result change input graph. Normally, graph actions automatically triggered every transformation step function allows manual triggering graph actions setting , example.","code":""},{"path":"/reference/trigger_graph_actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"","code":"trigger_graph_actions(graph)"},{"path":"/reference/trigger_graph_actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/trigger_graph_actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"graph object class dgr_graph.","code":""},{"path":"/reference/trigger_graph_actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Trigger the execution of a series of graph actions — trigger_graph_actions","text":"","code":"# Create a random graph using the # `add_gnm_graph()` function graph <- create_graph() %>% add_gnm_graph( n = 5, m = 10, set_seed = 23) # Add a graph action that sets a node # attr column with a function; this # uses the `get_pagerank()` function # to provide PageRank values in the # `pagerank` column graph <- graph %>% add_graph_action( fcn = \"set_node_attr_w_fcn\", node_attr_fcn = \"get_pagerank\", column_name = \"pagerank\", action_name = \"get_pagerank\") # Add a second graph action (to be # executed after the first one) that # rescales values in the `pagerank` # column between 0 and 1, and, puts # these values in the `width` column graph <- graph %>% add_graph_action( fcn = \"rescale_node_attrs\", node_attr_from = \"pagerank\", node_attr_to = \"width\", action_name = \"pgrnk_to_width\") # Add a third and final graph action # (to be executed last) that creates # color values in the `fillcolor` column, # based on the numeric values from the # `width` column graph <- graph %>% add_graph_action( fcn = \"colorize_node_attrs\", node_attr_from = \"width\", node_attr_to = \"fillcolor\", action_name = \"pgrnk_fillcolor\") # View the graph actions for the graph # object by using the `get_graph_actions()` # function graph %>% get_graph_actions() #> # A tibble: 3 × 3 #> action_index action_name expression #> #> 1 1 get_pagerank set_node_attr_w_fcn(graph = graph, node_attr_fcn… #> 2 2 pgrnk_to_width rescale_node_attrs(graph = graph, node_attr_from… #> 3 3 pgrnk_fillcolor colorize_node_attrs(graph = graph, node_attr_fro… # Manually trigger to invocation of # the graph actions using the # `trigger_graph_actions()` function graph <- graph %>% trigger_graph_actions() # Examine the graph's internal node # data frame (ndf) to verify that # the `pagerank`, `width`, and # `fillcolor` columns are present graph %>% get_node_df() #> id type label pagerank width fillcolor #> 1 1 1 0.2877 0.935 #ABDDA4 #> 2 2 2 0.0940 0.000 #D7191C #> 3 3 3 0.3012 1.000 #2B83BA #> 4 4 4 0.1965 0.495 #FFFFBF #> 5 5 5 0.1206 0.128 #FDAE61"},{"path":"/reference/usd_exchange_rates.html","id":null,"dir":"Reference","previous_headings":"","what":"US Dollar exchange rates. — usd_exchange_rates","title":"US Dollar exchange rates. — usd_exchange_rates","text":"dataset containing exchange rates USD currencies.","code":""},{"path":"/reference/usd_exchange_rates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"US Dollar exchange rates. — usd_exchange_rates","text":"","code":"usd_exchange_rates"},{"path":"/reference/usd_exchange_rates.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"US Dollar exchange rates. — usd_exchange_rates","text":"data frame 196 rows 3 variables: from_currency currency units used buy units alternate currency (always USD) to_currency currency bought cost_unit cost per unit currency bought","code":""},{"path":"/reference/visnetwork.html","id":null,"dir":"Reference","previous_headings":"","what":"Render graph with visNetwork — visnetwork","title":"Render graph with visNetwork — visnetwork","text":"Render graph object visNetwork R package.","code":""},{"path":"/reference/visnetwork.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Render graph with visNetwork — visnetwork","text":"","code":"visnetwork(graph)"},{"path":"/reference/visnetwork.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Render graph with visNetwork — visnetwork","text":"graph graph object class dgr_graph.","code":""},{"path":"/reference/visnetwork.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Render graph with visNetwork — visnetwork","text":"","code":"# Create a node data frame (ndf) ndf <- create_node_df( n = 6, label = TRUE, fillcolor = c(\"lightgrey\", \"red\", \"orange\", \"pink\", \"aqua\", \"yellow\"), shape = \"dot\", size = c(20, 80, 40, 10, 30, 50), type = c(\"1\", \"1\", \"1\", \"2\", \"2\", \"2\") ) # Create an edge data frame (edf) edf <- create_edge_df( from = c(1, 2, 3, 4, 6, 5), to = c(4, 3, 1, 3, 1, 4), color = c(\"green\", \"green\", \"grey\", \"grey\", \"blue\", \"blue\"), rel = \"leading_to\" ) # Create a graph object graph <- create_graph( nodes_df = ndf, edges_df = edf ) # visnetwork(graph)"},{"path":"/reference/x11_hex.html","id":null,"dir":"Reference","previous_headings":"","what":"X11 colors and hexadecimal color values — x11_hex","title":"X11 colors and hexadecimal color values — x11_hex","text":"Create data frame containing information X11 colors corresponding hexadecimal color values.","code":""},{"path":"/reference/x11_hex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"X11 colors and hexadecimal color values — x11_hex","text":"","code":"x11_hex()"},{"path":"/news/index.html","id":"diagrammer-development-version","dir":"Changelog","previous_headings":"","what":"DiagrammeR (development version)","title":"DiagrammeR (development version)","text":"DiagrammeR nows uses testthat 3rd edition (@olivroy, #498) longer use deprecated features igraph tidyselect (>= 1.2.0) (@olivroy, #497) Error messages reviewed now use cli (@olivroy, #499, #502) now easier install suggested packages fly. DiagrammeR now uses rlang::check_installed() internally. (@olivroy, #499)","code":""},{"path":"/news/index.html","id":"diagrammer-1010","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.10","title":"DiagrammeR 1.0.10","text":"CRAN release: 2023-05-18 Remove dependency influenceR package, also means removing get_constraint() get_bridging() graph inspection functions.","code":""},{"path":"/news/index.html","id":"diagrammer-109","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.9","title":"DiagrammeR 1.0.9","text":"CRAN release: 2022-03-05 safely check inputs grViz() mermaid()","code":""},{"path":"/news/index.html","id":"diagrammer-108","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.8","title":"DiagrammeR 1.0.8","text":"CRAN release: 2022-01-24 Reduce minimum R version requirement.","code":""},{"path":"/news/index.html","id":"diagrammer-107","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.7","title":"DiagrammeR 1.0.7","text":"CRAN release: 2022-01-15 Fix malformed CSS selector htmlwidgets/grViz.js call replace_na(replace = \"\") character columns Added envir argument grViz replace_in_spec functions.","code":""},{"path":"/news/index.html","id":"diagrammer-1061","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.6.1","title":"DiagrammeR 1.0.6.1","text":"CRAN release: 2020-05-08 Removed set_df_as_node_attr(), set_df_as_edge_attr(), get_attr_dfs() functions.","code":""},{"path":"/news/index.html","id":"diagrammer-105","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.5","title":"DiagrammeR 1.0.5","text":"CRAN release: 2020-01-16 Removes ability save DiagrammeR graph object Gephi file (.gexf) since rgexf package longer maintained","code":""},{"path":"/news/index.html","id":"diagrammer-100","dir":"Changelog","previous_headings":"","what":"DiagrammeR 1.0.0","title":"DiagrammeR 1.0.0","text":"CRAN release: 2018-03-01 Added helper functions node_aes(), node_data(), edge_aes(), edge_data() facilitate binding node edge aesthetic data attribute values; several functions now namesake arguments accept functions’ output. Information graph now displayed console graph object called Error messages now helpful try provide pointers common errors","code":""},{"path":"/news/index.html","id":"diagrammer-092","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.9.2","title":"DiagrammeR 0.9.2","text":"CRAN release: 2017-09-06 Added functions generate 2D 3D grid graphs (add_grid_2d() add_grid_3d()) Added _ws (selection) variants mutate_[node/edge]_attrs() functions mutating node edge attributes nodes/edges active selection Incorporated edges argument select_edges() function order filter selection edges set edge ID values Reduced dependency R version >= 3.2.0","code":""},{"path":"/news/index.html","id":"diagrammer-092-1","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.9.2","title":"DiagrammeR 0.9.2","text":"CRAN release: 2017-09-06 Added functions generate 2D 3D grid graphs (add_grid_2d() add_grid_3d()) Added _ws (selection) variants mutate_[node/edge]_attrs() functions mutating node edge attributes nodes/edges active selection Incorporated edges argument select_edges() function order filter selection edges set edge ID values Reduced dependency R version >= 3.2.0","code":""},{"path":"/news/index.html","id":"diagrammer-091","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.9.1","title":"DiagrammeR 0.9.1","text":"CRAN release: 2017-08-21 Simplified many functions internally Added default print method graph objects Allowed use bare node edge attribute names many functions Implemented graph actions means run one functions every graph transformation step; example, can used automatically update node attribute betweenness whenever modifications graph made (e.g., adding nodes, removing edges, etc.) Data frames can set node edge attributes set_df_as_node_attr() set_df_as_edge_attr() functions; get_attr_dfs() function allows retrieval stored data frame data Added two new graph-generating functions (add_gnp_graph(), add_pa_graph(), create_complement_graph()) Added functions clone existing nodes edges (add_n_node_clones() add_edge_clone()) Added several count_* functions (count_asymmetric_node_pairs(), count_automorphisms(), etc.) Added new functions obtain graph properties (get_adhesion(), get_girth(), get_reciprocity(), etc.) Added several is_* functions graph edge properties (e.g., is_edge_loop(), is_graph_dag(), etc.) mutate_node_attrs() mutate_edge_attrs() functions now simpler powerful interfaces mutating node edge attributes Graphs can easily saved disk (read disk) using save_graph() open_graph() functions","code":""},{"path":"/news/index.html","id":"diagrammer-090","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.9.0","title":"DiagrammeR 0.9.0","text":"CRAN release: 2017-01-03 Modified basic structure node edge data frames ID values automatically set integer values Just nodes , edges now edge ID values (can obtained using get_edge_ids() can used directly select_edges_by_edge_id() function) created, graph object automatically generates graph ID graph name (can modified using set_graph_name()) long node label values unique, may now used compose edges using add_edge() function use_labels = TRUE Quickly flexibly add color nodes edges using colorize_node_attrs() colorize_edge_attrs() functions Added functions selectively modify existing node edge attributes: copy_[node/edge]_attrs(), drop_[node/edge]_attrs(), mutate_[node/edge]_attrs(), recode_[node/edge]_attrs(), rename_[node/edge]_attrs(), rescale_[node/edge]_attrs(). New node edge attributes can now easily added graph via data frame using join_node_attrs() join_edge_attrs() functions Several graph generators available quickly adding graph primitives graph object (add_balanced_tree(), add_cycle(), add_full_graph(), add_path(), add_prism(), add_star()) traversal functions can now migrate numeric node edge attribute values traversed edges (e.g., trav_out_edge(), trav_in_node()) providing attribute name copy_attrs_from; traversal functions nodes edges may receive multiple values, one can specify aggregation type agg argument (e.g,. trav_in_node(), trav_both_edge()) Multiple conditions can specified traversal types select_nodes() select_edges() functions, plus, much easier write Added mk_cond() helper function creating conditions traversal functions (trav_...()), , select_nodes() select_edges() functions; helper allows easier composition selection/traversal conditions using variables /function calls selection edges one can now use select_rev_edges_ws() transform selection selected edges’ reverse edges (available); option add reverse edges edge selection simply replace current selection Caching attributes later use made simpler collection cache_...() functions (, set cache explicitly using set_cache()); get graph’s cache using get_cache() function Added functions allow layout control nodes (set_node_position(), layout_nodes_w_string(), nudge_node_positions()) Added functions convert DiagrammeR graphs igraph graphs vice versa (to_igraph(), from_igraph()) Now can create graph adjacency matrix (from_adj_matrix()) Added functions get community membership variety algorithms: get_cmty_edge_btwns(), get_cmty_fast_greedy(), get_cmty_l_eigenvec(), get_cmty_louvain(), get_cmty_walktrap(). Added functions determine similarity coefficient scores graph nodes: get_dice_similarity() get_dice_similarity(). Constraint scores nodes can now determined using get_constraint() function Functions getting information nodes neighbors added: get_nbrs(), get_non_nbrs(), get_similar_nbrs(). Groups nodes weakly strongly connected components can determined using get_w_connected_cmpts() get_s_connected_cmpts() functions Get articulation points (.e., nodes , removed, disconnect graph) get_articulation_points() function Obtain centrality measures graph nodes using get_closeness() get_betweenness() functions Get minimum-spanning tree subgraph graph weighted edges using get_min_spanning_tree() function edge direction may reversed entire graph (rev_edge_dir()) part graph using edge selection (rev_edge_dir_ws()) Depth-first search breadth-first search algorithms available do_dfs() do_bfs() functions Degree data plots can now easily obtained using get_degree_distribution() get_degree_histogram() functions Global graph attributes now easily modifiable using set functions purpose: add_global_graph_attrs(), delete_global_graph_attrs(), get_global_graph_attr_info(). Added option display different text labels nodes via display node attribute; easily set set_node_attr_to_display() function Rewrote many graph functions (e.g. traversals) faster large graphs log graph functions directly modify graph now part graph object (graph$graph_log) Added functionality automatically generate graph backups every graph modification; form RDS files deposited subdirectory (name based graph ID) working directory; option (write_backups, set FALSE default) available functions initialize graph object (create_graph(), create_random_graph(), from_igraph(), from_adj_matrix())","code":""},{"path":"/news/index.html","id":"diagrammer-08","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.8","title":"DiagrammeR 0.8","text":"CRAN release: 2015-10-08 Revised many graph functions work better together Added many testthat tests maintain quality graph functions Added functions create_random_graph(), import_graph(), combine_graphs(), country_graph() select_graph_from_series() Added support visNetwork graphs rendering option render_graph()","code":""},{"path":"/news/index.html","id":"diagrammer-07","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.7","title":"DiagrammeR 0.7","text":"CRAN release: 2015-06-11 Renamed functions graphviz_graph() graphviz_render() create_graph() render_graph(), respectively Removed function graphviz_export() (exporting now handled render_graph()) Added several new functions inspect, analyze, modify graphs: display_graph_object(), node_info(), edge_info(), node_present(), edge_present(), get_nodes(), get_edges(), get_predecessors(), get_successors(), node_count(), edge_count(), is_graph_empty(), is_graph_directed(), add_node(), add_edges(), delete_node(), delete_edge(), node_type(), edge_relationship(), create_series(), add_to_series(), remove_from_series(), graph_count(), subset_series(), trigger_script(), render_graph_from_series(), series_info()","code":""},{"path":"/news/index.html","id":"diagrammer-06","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.6","title":"DiagrammeR 0.6","text":"CRAN release: 2015-04-30 Added several functions work graphs: create_nodes(), create_edges(), combine_nodes(), combine_edges(), scale_nodes(), scale_edges(), get_nodes(), node_info(), graphviz_graph(), graphviz_render(), graphviz_export() Removed graphviz_nodes_edges_df() graphviz_single_df() functions","code":""},{"path":"/news/index.html","id":"diagrammer-05","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.5","title":"DiagrammeR 0.5","text":"CRAN release: 2015-03-19 Added support subgraphs Gantt charts mermaid diagrams Added function graphviz_nodes_edges_df() generating Graphviz DOT code defines nodes edges (attributes) data two data frames: one nodes, edge operations Added function graphviz_single_df() generating Graphviz DOT code single data frame Incorporated new substitution operators @_{...} @^{...} grViz statements subscripting superscripting, respectively","code":""},{"path":"/news/index.html","id":"diagrammer-04","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.4","title":"DiagrammeR 0.4","text":"CRAN release: 2015-01-30 Added support substitution Graphviz graph specifications Added support Graphviz diagrams Shiny app","code":""},{"path":"/news/index.html","id":"diagrammer-03","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.3","title":"DiagrammeR 0.3","text":"Added support Graphviz neato, twopi, circo engines","code":""},{"path":"/news/index.html","id":"diagrammer-02","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.2","title":"DiagrammeR 0.2","text":"Added viz.js library enable Graphviz support","code":""},{"path":"/news/index.html","id":"diagrammer-01","dir":"Changelog","previous_headings":"","what":"DiagrammeR 0.1","title":"DiagrammeR 0.1","text":"CRAN release: 2015-01-09 Initial release Incorporated htmlwidgets framework Added basic shiny app","code":""}]