DiagrammeR (version 0.9.0)

import_graph: Import a graph from various graph formats

Description

Import a variety of graphs from different graph formats and create a graph object.

Usage

import_graph(graph_file, file_type = NULL)

Arguments

graph_file

a connection to a graph file.

file_type

the type of file to be imported. Options are: graphml (GraphML), gml (GML), sif (SIF), edges (a .edges file), and mtx (MatrixMarket format). If not supplied, the function will infer the type by its file extension.

Value

a graph object of class dgr_graph.

Examples

Run this code
# NOT RUN {
# Import a GraphML graph file
graphml_graph <-
  import_graph(
    system.file("extdata", "power_grid.graphml",
                package = "DiagrammeR"))

# Get a count of the graph's nodes
graphml_graph %>% node_count
#> [1] 4941

# Get a count of the graph's edges
graphml_graph %>% edge_count
#> [1] 6594

# Import an SIF graph file
sif_graph <-
  import_graph(
    system.file("extdata", "Human_Interactome.sif",
                package = "DiagrammeR"))

# Get a count of the graph's nodes
sif_graph %>% node_count
#> [1] 8347

# Get a count of the graph's edges
sif_graph %>% edge_count
#> [1] 61263

# 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 %>% node_count
#> [1] 34

# Get a count of the graph's edges
gml_graph %>% edge_count
#> [1] 78
# }

Run the code above in your browser using DataLab