Tulip  6.0.0
Large graphs analysis and drawing
tlp::SimpleTest Class Reference

#include <SimpleTest.h>

Static Public Member Functions

static bool hasLoops (const Graph *graph)
 
static bool hasParallelEdges (const Graph *graph, const bool directed=false)
 
static bool isSimple (const Graph *graph, const bool directed=false)
 
static void makeSimple (Graph *graph, std::vector< edge > &removed, const bool directed=false)
 
static bool simpleTest (const Graph *graph, std::vector< edge > *multipleEdges=nullptr, std::vector< edge > *loops=nullptr, const bool directed=false)
 

Detailed Description

Performs test to check if a graph is Simple. An undirected graph is simple if it has no loops and no more than one edge between any unordered pair of vertices. A directed graph is simple if has no loops and no more than one edge between any ordered pair of vertices.

Definition at line 40 of file SimpleTest.h.

Member Function Documentation

◆ hasLoops()

static bool tlp::SimpleTest::hasLoops ( const Graph graph)
static

Checks if the graph has self loop edges.

Parameters
graphThe graph to check.
Returns
bool True if the graph has loops, false otherwise.

◆ hasParallelEdges()

static bool tlp::SimpleTest::hasParallelEdges ( const Graph graph,
const bool  directed = false 
)
static

Checks if the graph has parallel edges.

Parameters
graphThe graph to check.
directedWhether the graph shall be considered directed or not.
Returns
bool True if the graph has parallel edges, false otherwise.

◆ isSimple()

static bool tlp::SimpleTest::isSimple ( const Graph graph,
const bool  directed = false 
)
static

Checks if the graph is simple (i.e. it contains no self loops or parallel edges).

Parameters
graphThe graph to check.
directedWhether the graph shall be considered directed or not.
Returns
bool True if the graph is simple, false otherwise.

◆ makeSimple()

static void tlp::SimpleTest::makeSimple ( Graph graph,
std::vector< edge > &  removed,
const bool  directed = false 
)
static

Makes the graph simple, by removing self loops and parallel edges if any.

Makes the graph simple by removing self loops and parallel edges if any. The removed edges are stored in the removed vector.

Parameters
graphThe graph to make simple.
removedThe edges that were removed to make the graph simple.
directedWhether the graph shall be considered directed or not.
Returns
void

◆ simpleTest()

static bool tlp::SimpleTest::simpleTest ( const Graph graph,
std::vector< edge > *  multipleEdges = nullptr,
std::vector< edge > *  loops = nullptr,
const bool  directed = false 
)
static

Checks if the graph is simple, and stores parallel edges and self loops in different vectors.

Performs simple test and stores found parallel edges in the multipleEdges vector and found self loops in the loops vector. Returns true if the graph is simple, false otherwise.

Parameters
graphThe graph to check for simplicity.
multipleEdgesThe parallel edges that need to be removed to make the graph simple. Defaults to 0.
loopsThe self loops that need to be removed to make the graph simple. Defaults to 0.
directedWhether the graph shall be considered directed or not.
Returns
bool True if the graph is simple, false otherwise.