- Home
- CRAN
**igraph**: Network Analysis and Visualization**graph_from_edgelist**: Create a graph from an edge list matrix

# Create a graph from an edge list matrix

### Description

`graph_from_edgelist`

creates a graph from an edge list. Its argument
is a two-column matrix, each row defines one edge. If it is
a numeric matrix then its elements are interpreted as vertex ids. If
it is a character matrix then it is interpreted as symbolic vertex
names and a vertex id will be assigned to each name, and also a
`name`

vertex attribute will be added.

### Usage

1 2 3 | ```
graph_from_edgelist(el, directed = TRUE)
from_edgelist(...)
``` |

### Arguments

`el` |
The edge list, a two column matrix, character or numeric. |

`directed` |
Whether to create a directed graph. |

`...` |
Passed to |

### Value

An igraph graph.

### See Also

Other determimistic constructors: `atlas`

,
`graph.atlas`

,
`graph_from_atlas`

;
`chordal_ring`

,
`graph.extended.chordal.ring`

,
`make_chordal_ring`

;
`directed_graph`

, `graph`

,
`graph.famous`

,
`make_directed_graph`

,
`make_graph`

,
`make_undirected_graph`

,
`undirected_graph`

;
`empty_graph`

, `graph.empty`

,
`make_empty_graph`

;
`from_literal`

, `graph.formula`

,
`graph_from_literal`

;
`full_citation_graph`

,
`graph.full.citation`

,
`make_full_citation_graph`

;
`full_graph`

, `graph.full`

,
`make_full_graph`

;
`graph.lattice`

, `lattice`

,
`make_lattice`

; `graph.ring`

,
`make_ring`

, `ring`

;
`graph.star`

, `make_star`

,
`star`

; `graph.tree`

,
`make_tree`

, `tree`

### Examples

1 2 3 4 5 | ```
el <- matrix( c("foo", "bar", "bar", "foobar"), nc = 2, byrow = TRUE)
graph_from_edgelist(el)
# Create a ring by hand
graph_from_edgelist(cbind(1:10, c(2:10, 1)))
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.

- aaa-igraph-package: The igraph package
- add_edges: Add edges to a graph
- add_layout_: Add layout to graph
- add_vertices: Add vertices to a graph
- adjacent_vertices: Adjacent vertices of multiple vertices in a graph
- all_simple_paths: List all simple paths from one source
- alpha_centrality: Find Bonacich alpha centrality scores of network positions
- are_adjacent: Are two vertices adjacent?
- arpack: ARPACK eigenvector calculation
- articulation_points: Articulation points of a graph
- as_adjacency_matrix: Convert a graph to an adjacency matrix
- as_adj_list: Adjacency lists
- as.directed: Convert between directed and undirected graphs
- as_edgelist: Convert a graph to an edge list
- as_graphnel: Convert igraph graphs to graphNEL objects from the graph...
- as_ids: Convert a vertex or edge sequence to an ordinary vector
- as.igraph: Conversion to igraph
- as_incidence_matrix: Incidence matrix of a bipartite graph
- as_long_data_frame: Convert a graph to a long data frame
- as_membership: Declare a numeric vector as a membership vector
- assortativity: Assortativity coefficient
- authority_score: Kleinberg's authority centrality scores.
- automorphisms: Number of automorphisms
- betweenness: Vertex and edge betweenness centrality
- bfs: Breadth-first search
- biconnected_components: Biconnected components
- bipartite_mapping: Decide whether a graph is bipartite
- bipartite_projection: Project a bipartite graph
- canonical_permutation: Canonical permutation of a graph
- categorical_pal: Palette for categories
- centralize: Centralization of a graph
- centr_betw: Centralize a graph according to the betweenness of vertices
- centr_betw_tmax: Theoretical maximum for betweenness centralization
- centr_clo: Centralize a graph according to the closeness of vertices
- centr_clo_tmax: Theoretical maximum for closeness centralization
- centr_degree: Centralize a graph according to the degrees of vertices
- centr_degree_tmax: Theoretical maximum for degree centralization
- centr_eigen: Centralize a graph according to the eigenvector centrality of...
- centr_eigen_tmax: Theoretical maximum for betweenness centralization
- c.igraph.es: Concatenate edge sequences
- c.igraph.vs: Concatenate vertex sequences
- cliques: The functions find cliques, ie. complete subgraphs in a graph
- closeness: Closeness centrality of vertices
- cluster_edge_betweenness: Community structure detection based on edge betweenness
- cluster_fast_greedy: Community structure via greedy optimization of modularity
- cluster_infomap: Infomap community finding
- cluster_label_prop: Finding communities based on propagating labels
- cluster_leading_eigen: Community structure detecting based on the leading...
- cluster_louvain: Finding community structure by multi-level optimization of...
- cluster_optimal: Optimal community structure
- cluster_spinglass: Finding communities in graphs based on statistical meachanics
- cluster_walktrap: Community strucure via short random walks
- cocitation: Cocitation coupling
- cohesive_blocks: Calculate Cohesive Blocks
- communities: Functions to deal with the result of network community...
- compare: Compares community structures using various metrics
- complementer: Complementer of a graph
- components: Connected components of a graph
- component_wise: Component-wise layout
- compose: Compose two graphs as binary relations
- consensus_tree: Create a consensus tree from several hierarchical random...
- console: The igraph console
- constraint: Burt's constraint
- contract: Contract several vertices into a single one
- convex_hull: Convex hull of a set of vertices
- coreness: K-core decomposition of graphs
- count_isomorphisms: Count the number of isomorphic mappings between two graphs
- count_motifs: Graph motifs
- count_subgraph_isomorphisms: Count the isomorphic mappings between a graph and the...
- count_triangles: Find triangles in graphs
- curve_multiple: Optimal edge curvature when plotting graphs
- decompose: Decompose a graph into components
- degree: Degree and degree distribution of the vertices
- delete_edge_attr: Delete an edge attribute
- delete_edges: Delete edges from a graph
- delete_graph_attr: Delete a graph attribute
- delete_vertex_attr: Delete a vertex attribute
- delete_vertices: Delete vertices from a graph
- dfs: Depth-first search
- diameter: Diameter of a graph
- difference: Difference of two sets
- difference.igraph: Difference of graphs
- difference.igraph.es: Difference of edge sequences
- difference.igraph.vs: Difference of vertex sequences
- dim_select: Dimensionality selection for singular values using profile...
- disjoint_union: Disjoint union of graphs
- distances: Shortest (directed or undirected) paths between vertices
- diverging_pal: Diverging palette
- diversity: Graph diversity
- dominator_tree: Dominator tree
- dyad_census: Dyad census of a graph
- E: Edges of a graph
- each_edge: Rewires the endpoints of the edges of a graph to a random...
- eccentricity: Eccentricity of the vertices in a graph
- edge: Helper function for adding and deleting edges
- edge_attr: Query edge attributes of a graph
- edge_attr_names: List names of edge attributes
- edge_attr-set: Set one or more edge attributes
- edge_connectivity: Edge connectivity.
- edge_density: Graph density
- ego: Neighborhood of graph vertices
- eigen_centrality: Find Eigenvector Centrality Scores of Network Positions
- embed_adjacency_matrix: Spectral Embedding of Adjacency Matrices
- embed_laplacian_matrix: Spectral Embedding of the Laplacian of a Graph
- ends: Incident vertices of some graph edges
- erdos.renyi.game: Generate random graphs according to the Erdos-Renyi model
- fit_hrg: Fit a hierarchical random graph model
- fit_power_law: Fitting a power-law distribution function to discrete data
- gclust.app: Graph Clustering Using NMF (and no SVT) - Apparent Clusters
- gclust.rsvt: Graph Clustering Using SVT and NMF - Clusters Implied by...
- getAICc: Compute AIC based on a Poisson Approximation using the output...
- get.edge.ids: Find the edge ids based on the incident vertices of the edges
- girth: Girth of a graph
- gorder: Order (number of vertices) of a graph
- graph_: Convert object to a graph
- graph_attr: Graph attributes of a graph
- graph_attr_names: List names of graph attributes
- graph_attr-set: Set all or some graph attributes
- graph_from_adjacency_matrix: Create graphs from adjacency matrices
- graph_from_adj_list: Create graphs from adjacency lists
- graph_from_atlas: Create a graph from the Graph Atlas
- graph_from_data_frame: Creating igraph graphs from data frames or vice-versa
- graph_from_edgelist: Create a graph from an edge list matrix
- graph_from_graphdb: Load a graph from the graph database for testing graph...
- graph_from_graphnel: Convert graphNEL objects from the graph package to igraph
- graph_from_incidence_matrix: Create graphs from an incidence matrix
- graph_from_isomorphism_class: Create a graph from an isomorphism class
- graph_from_lcf: Creating a graph from LCF notation
- graph_from_literal: Creating (small) graphs via a simple interface
- graphlet_basis: Graphlet decomposition of a graph
- graph_version: Igraph data structure versions
- groups: Groups of a vertex partitioning
- gsize: The size of the graph (number of edges)
- head_of: Head of the edge(s) in a graph
- hrg: Create a hierarchical random graph from an igraph graph
- hrg-methods: Hierarchical random graphs
- hrg_tree: Create an igraph graph from a hierarchical random graph model
- hub_score: Kleinberg's hub centrality scores.
- identical_graphs: Decide if two graphs are identical
- igraph-attribute-combination: How igraph functions handle attributes when the graph changes
- igraph_demo: Run igraph demos, step by step
- igraph-dollar: Getting and setting graph attributes, shortcut
- igraph-es-attributes: Query or set attributes of the edges in an edge sequence
- igraph-es-indexing: Indexing edge sequences
- igraph-es-indexing2: Select edges and show their metadata
- igraph-minus: Delete vertices or edges from a graph
- igraph_options: Parameters for the igraph package
- igraph_test: Run package tests
- igraph_version: Query igraph's version string
- igraph-vs-attributes: Query or set attributes of the vertices in a vertex sequence
- igraph-vs-indexing: Indexing vertex sequences
- igraph-vs-indexing2: Select vertices and show their metadata
- incident: Incident edges of a vertex in a graph
- incident_edges: Incident edges of multiple vertices in a graph
- intersection: Intersection of two or more sets
- intersection.igraph: Intersection of graphs
- intersection.igraph.es: Intersection of edge sequences
- intersection.igraph.vs: Intersection of vertex sequences
- is_chordal: Chordality of a graph
- is_dag: Directed acyclic graphs
- is_degseq: Check if a degree sequence is valid for a multi-graph
- is_directed: Check whether a graph is directed
- is_graphical: Is a degree sequence graphical?
- is_igraph: Is this object an igraph graph?
- is_min_separator: Minumal vertex separators
- is_named: Named graphs
- isomorphic: Decide if two graphs are isomorphic
- isomorphism_class: Isomorphism class of a graph
- isomorphisms: Calculate all isomorphic mappings between the vertices of two...
- is_separator: Vertex separators
- is_weighted: Weighted graphs
- ivs: Independent vertex sets
- keeping_degseq: Graph rewiring while preserving the degree distribution
- knn: Average nearest neighbor degree
- laplacian_matrix: Graph Laplacian
- layout_: Graph layouts
- layout_as_bipartite: Simple two-row layout for bipartite graphs
- layout_as_star: Generate coordinates to place the vertices of a graph in a...
- layout_as_tree: The Reingold-Tilford graph layout algorithm
- layout.deprecated: Deprecated layout functions
- layout.fruchterman.reingold.grid: Grid Fruchterman-Reingold layout, this was removed from...
- layout_in_circle: Graph layout with vertices on a circle.
- layout_nicely: Choose an appropriate graph layout algorithm automatically
- layout_on_grid: Simple grid layout
- layout_on_sphere: Graph layout with vertices on the surface of a sphere
- layout_randomly: Randomly place vertices on a plane or in 3d space
- layout.spring: Spring layout, this was removed from igraph
- layout.svd: SVD layout, this was removed from igraph
- layout_with_dh: The Davidson-Harel layout algorithm
- layout_with_drl: The DrL graph layout generator
- layout_with_fr: The Fruchterman-Reingold layout algorithm
- layout_with_gem: The GEM layout algorithm
- layout_with_graphopt: The graphopt layout algorithm
- layout_with_kk: The Kamada-Kawai layout algorithm
- layout_with_lgl: Large Graph Layout
- layout_with_mds: Graph layout by multidimensional scaling
- layout_with_sugiyama: The Sugiyama graph layout generator
- local_scan: Compute local scan statistics on graphs
- make_: Make a new graph
- make_bipartite_graph: Create a bipartite graph
- make_chordal_ring: Create an extended chordal ring graph
- make_clusters: Creates a communities object.
- make_de_bruijn_graph: De Bruijn graphs
- make_empty_graph: A graph with no edges
- make_full_bipartite_graph: Create a full bipartite graph
- make_full_citation_graph: Create a complete (full) citation graph
- make_full_graph: Create a full graph
- make_graph: Create an igraph graph from a list of edges, or a notable...
- make_kautz_graph: Kautz graphs
- make_lattice: Create a lattice graph
- make_line_graph: Line graph of a graph
- make_ring: Create a ring graph
- make_star: Create a star graph, a tree with n vertices and n - 1 leaves
- make_tree: Create tree graphs
- matching: Graph matching
- match_vertices: Match Graphs given a seeding of vertex correspondences
- max_cardinality: Maximum cardinality search
- max_flow: Maximum flow in a graph
- merge_coords: Merging graph layouts
- min_cut: Minimum cut in a graph
- min_separators: Minimum size vertex separators
- min_st_separators: Minimum size vertex separators
- modularity.igraph: Modularity of a community structure of a graph
- motifs: Graph motifs
- mst: Minimum spanning tree
- neighbors: Neighboring (adjacent) vertices in a graph
- nexus: Query and download from the Nexus network repository
- normalize: Normalize layout
- norm_coords: Normalize coordinates for plotting graphs
- page_rank: The Page Rank algorithm
- path: Helper function to add or delete edges along a path
- permute: Permute the vertices of a graph
- pipe: Magrittr's pipes
- plot.common: Drawing graphs
- plot_dendrogram.communities: Community structure dendrogram plots
- plot_dendrogram.igraphHRG: HRG dendrogram plot
- plot.igraph: Plotting of graphs
- plot.sir: Plotting the results on multiple SIR model runs
- plus-.igraph: Add vertices, edges or another graph to a graph
- power_centrality: Find Bonacich Power Centrality Scores of Network Positions
- predict_edges: Predict edges based on a hierarchical random graph model
- print.igraph: Print graphs to the terminal
- print.igraph.es: Print an edge sequence to the screen
- print.igraphHRG: Print a hierarchical random graph model to the screen
- print.igraphHRGConsensus: Print a hierarchical random graph consensus tree to the...
- print.igraph.vs: Show a vertex sequence on the screen
- radius: Radius of a graph
- random_walk: Random walk on a graph
- read_graph: Reading foreign file formats
- reciprocity: Reciprocity of graphs
- rep.igraph: Replicate a graph multiple times
- rev.igraph.es: Reverse the order in an edge sequence
- rev.igraph.vs: Reverse the order in a vertex sequence
- rewire: Rewiring edges of a graph
- rglplot: 3D plotting of graphs with OpenGL
- r_pal: The default R palette
- running_mean: Running mean of a time series
- sample_: Sample from a random graph model
- sample_bipartite: Bipartite random graphs
- sample_correlated_gnp: Generate a new random graph from a given graph by randomly...
- sample_correlated_gnp_pair: Sample a pair of correlated G(n,p) random graphs
- sample_degseq: Generate random graphs with a given degree sequence
- sample_dirichlet: Sample from a Dirichlet distribution
- sample_dot_product: Generate random graphs according to the random dot product...
- sample_fitness: Random graphs from vertex fitness scores
- sample_fitness_pl: Scale-free random graphs, from vertex fitness scores
- sample_forestfire: Forest Fire Network Model
- sample_gnm: Generate random graphs according to the G(n,m) Erdos-Renyi...
- sample_gnp: Generate random graphs according to the G(n,p) Erdos-Renyi...
- sample_grg: Geometric random graphs
- sample_growing: Growing random graph generation
- sample_hierarchical_sbm: Sample the hierarchical stochastic block model
- sample_hrg: Sample from a hierarchical random graph model
- sample_islands: A graph with subgraphs that are each a random graph.
- sample_k_regular: Create a random regular graph
- sample_last_cit: Random citation graphs
- sample_motifs: Graph motifs
- sample_pa: Generate scale-free graphs according to the Barabasi-Albert...
- sample_pa_age: Generate an evolving random graph with preferential...
- sample_pref: Trait-based random generation
- sample_sbm: Sample stochastic block model
- sample_seq: Sampling a random integer sequence
- sample_smallworld: The Watts-Strogatz small-world model
- sample_sphere_surface: Sample vectors uniformly from the surface of a sphere
- sample_sphere_volume: Sample vectors uniformly from the volume of a sphere
- sample_traits_callaway: Graph generation based on different vertex types
- scan_stat: Scan statistics on a time series of graphs
- scg: All-in-one Function for the SCG of Matrices and Graphs
- scg_eps: Error of the spectral coarse graining (SCG) approximation
- scg_group: SCG Problem Solver
- scg-method: Spectral Coarse Graining
- scg_semi_proj: Semi-Projectors
- sequential_pal: Sequential palette
- set_edge_attr: Set edge attributes
- set_graph_attr: Set a graph attribute
- set_vertex_attr: Set vertex attributes
- shapes: Various vertex shapes when plotting igraph graphs
- similarity: Similarity measures of two vertices
- simplified: Constructor modifier to drop multiple and loop edges
- simplify: Simple graphs
- sir: SIR model on graphs
- spectrum: Eigenvalues and eigenvectors of the adjacency matrix of a...
- split_join_distance: Split-join distance of two community structures
- srand: Deprecated function, used to set random seed of the C...
- st_cuts: List all (s,t)-cuts of a graph
- st_min_cuts: List all minimum (s,t)-cuts of a graph
- stochastic_matrix: Stochastic matrix of a graph
- strength: Strength or weighted vertex degree
- subcomponent: In- or out- component of a vertex
- subgraph: Subgraph of a graph
- subgraph_centrality: Find subgraph centrality scores of network positions
- subgraph_isomorphic: Decide if a graph is subgraph isomorphic to another one
- subgraph_isomorphisms: All isomorphic mappings between a graph and subgraphs of...
- sub-.igraph: Query and manipulate a graph as it were an adjacency matrix
- sub-sub-.igraph: Query and manipulate a graph as it were an adjacency list
- tail_of: Tails of the edge(s) in a graph
- tkigraph: Experimental basic igraph GUI
- tkplot: Interactive plotting of graphs
- topo_sort: Topological sorting of vertices in a graph
- transitivity: Transitivity of a graph
- triad_census: Triad census, subgraphs with three vertices
- unfold_tree: Convert a general graph into a forest
- union: Union of two or more sets
- union.igraph: Union of graphs
- union.igraph.es: Union of edge sequences
- union.igraph.vs: Union of vertex sequences
- unique.igraph.es: Remove duplicate edges from an edge sequence
- unique.igraph.vs: Remove duplicate vertices from a vertex sequence
- upgrade_graph: Igraph data structure versions
- V: Vertices of a graph
- vertex: Helper function for adding and deleting vertices
- vertex_attr: Query vertex attributes of a graph
- vertex_attr_names: List names of vertex attributes
- vertex_attr-set: Set one or more vertex attributes
- vertex_connectivity: Vertex connectivity.
- vertex.shape.pie: Using pie charts as vertices in graph plots
- which_multiple: Find the multiple or loop edges in a graph
- which_mutual: Find mutual edges in a directed graph
- with_edge_: Constructor modifier to add edge attributes
- with_graph_: Constructor modifier to add graph attributes
- without_attr: Construtor modifier to remove all attributes from a graph
- without_loops: Constructor modifier to drop loop edges
- without_multiples: Constructor modifier to drop multiple edges
- with_vertex_: Constructor modifier to add vertex attributes
- write_graph: Writing the graph to a file in some format