generate_random_graph: Generate a Random Weighted Graph

View source: R/Dijkstra_graphGenerator.R

generate_random_graphR Documentation

Generate a Random Weighted Graph

Description

This function generates a random weighted graph with 'n' vertices and 'm' edges, where 'm' is determined based on the probability 'p' of an edge existing between any two vertices.

Usage

generate_random_graph(n, p)

Arguments

n

Integer. The number of vertices in the graph.

p

Numeric. The probability of an edge existing between two vertices.

Value

A data frame with three columns:

  • "v1": The first vertex of the edge.

  • "v2": The second vertex of the edge.

  • "cost": A random weight assigned to the edge (sampled from a normal distribution).

Examples

generate_random_graph(10, 0.5)


vrunge/M2algorithmique documentation built on April 5, 2025, 4:06 a.m.