Mescal
|
Implementation of graphs. More...
#include "type_abr.h"
#include "type_basic.h"
#include "type_binheap.h"
#include "type_dequeue.h"
#include "type_partitions.h"
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
Classes | |
struct | graph |
Type used to represent a directed unlabeled graph. More... | |
struct | lgraph |
Type used to represent a directed labeled graph. More... | |
struct | dgraph |
Type used to represent a complete deterministic directed labeled graph. More... | |
Enumerations | |
enum | graph_stype { DFS , BFS } |
Names for the two available algorithms for searches. | |
Functions | |
graph * | create_graph_noedges (uint) |
Creates a directed unlabeled graph without edges. | |
graph * | create_graph_selfloops (uint) |
Creates a directed unlabeled graph whose only edges are self-loops. | |
void | delete_graph (graph *) |
Releases a directed unlabeled graph. | |
graph * | copy_graph (graph *g) |
Makes a copy of a directed graph. | |
lgraph * | create_lgraph_noedges (uint, uint) |
Creates a directed graph without edges. | |
void | delete_lgraph (lgraph *) |
Releases a directed graph. | |
lgraph * | copy_lgraph (lgraph *g) |
Makes a copy of a labeled graph. | |
dgraph * | create_dgraph_noedges (uint, uint) |
Creates a complete deterministic directed graph without edges. | |
void | delete_dgraph (dgraph *) |
Release of a complete deterministic directed graph. | |
dgraph * | copy_dgraph (dgraph *g) |
Makes a copy of a complete deterministic directed graph. | |
int | graph_nb_edges (graph *) |
Computes the number of edges in a directed unlabeled graph. | |
int | lgraph_nb_edges (lgraph *) |
Computes the number of edges in a directed labeled graph. | |
int | dgraph_nb_edges (dgraph *) |
Computes the number of edges in a complete deterministic directed labeled graph. | |
dgraph * | dgraph_direct_product (dgraph *g1, dgraph *g2) |
Computes the direct product of two deterministic directed labeled graphs. | |
graph * | graph_mirror (graph *) |
Computes the mirror of a directed unlabeled graph. | |
lgraph * | lgraph_mirror (lgraph *) |
Computes the mirror of a directed labeled graph. | |
lgraph * | dgraph_mirror (dgraph *) |
Computes the mirror of a complete deterministic directed labeled graph. | |
void | graph_search_update (graph_stype, graph *, dequeue *, bool *) |
Searches in an unlabeled graph. A set of already visited vertices is taken as input. This set is updated by the search. | |
dequeue * | graph_search (graph_stype, graph *, dequeue *, bool *) |
Searches in an unlabeled graph. Reachable vertices are returned inside a dequeue sorted in increasing order. | |
void | lgraph_search_update (graph_stype, lgraph *, dequeue *, bool *, bool *) |
Search in a labeled graph. A set of already visited vertices is taken as input. This set is updated by the search. | |
dequeue * | lgraph_search (graph_stype, lgraph *, dequeue *, bool *, bool *) |
Search in a labeled graph. Reachable vertices are returned inside a dequeue sorted in increasing order. | |
void | dgraph_search_update (graph_stype, dgraph *, dequeue *, bool *, bool *) |
Search in a desterministic complete labeled graph. A set of already visited vertices is taken as input. This set is updated by the search. | |
dequeue * | dgraph_search (graph_stype, dgraph *, dequeue *, bool *, bool *) |
Search in a desterministic complete labeled graph. Reachable vertices are returned inside a dequeue sorted in increasing order. | |
void | twin_dgraph_search_update (graph_stype, dgraph *, dgraph *, dequeue *, bool *, bool *) |
Search in two deterministic complete labeled graphs (same set of vertices, same alphabet). A set of already visited vertices is taken as input. This set is updated by the search. | |
dequeue * | twin_dgraph_search (graph_stype, dgraph *, dgraph *, dequeue *, bool *, bool *) |
Search in two deterministic complete labeled graphs (same set of vertices, same alphabet). Reachable vertices are returned inside a dequeue sorted in increasing order. | |
dgraph * | dgraph_paths (dgraph *G, uint start) |
Computes a path from a given strating vertex to all other reachable vertices in a directed unlabeled graph. | |
graph * | merge_graphs (uint *, uint,...) |
Disjoint merge of an arbitrary number of unlabeled graphs. | |
lgraph * | merge_lgraphs (uint *, uint,...) |
Disjoint merge of an arbitrary number of labeled graphs. | |
graph * | ldgraphs_to_graph (uint, uint, uint, uint,...) |
Merging an arbitrary number of graphs using the same set of vertices into a single unlabeled graph. | |
lgraph * | ldgraphs_to_lgraph (uint, uint, uint,...) |
Merging an arbitrary number of labeled graphs using the same set of vertices into a single labeled graph. | |
lgraph * | dgraph_to_lgraph (dgraph *) |
Conversion of a complete deterministic labeled graph into a standard labeled graph. | |
graph * | lgraph_to_graph (lgraph *) |
Conversion of a standard labeled graph into a unlabeled graph. | |
graph * | lgraph_to_graph_alpha (lgraph *, bool *) |
Conversion of a standard labeled graph into a unlabeled graph. Restricted version. | |
graph * | dgraph_to_graph (dgraph *) |
Conversion of a deterministic labeled graph into a unlabeled graph. | |
graph * | dgraph_to_graph_alpha (dgraph *, bool *) |
Conversion of a deterministic labeled graph into a unlabeled graph. Restricted version. | |
dequeue * | lgraph_reachable (lgraph *, dequeue *, uint) |
Given a labeled graph, a list of vertices in this graph and a label, computes the list of all vertices connected to a vertex in the input list by an edge labeled by the input label. | |
Implementation of graphs.
Contains the various types used to represent graphs and some functions that can manipulate them.
Makes a copy of a complete deterministic directed graph.
g | The graph. |
Makes a copy of a directed graph.
g | The graph. |
Makes a copy of a labeled graph.
g | The graph. |
dgraph * create_dgraph_noedges | ( | uint | size_graph, |
uint | size_alpha ) |
Creates a complete deterministic directed graph without edges.
size_graph | Number of vertices. |
size_alpha | Number of labels. |
graph * create_graph_noedges | ( | uint | size | ) |
Creates a directed unlabeled graph without edges.
size | Number of vertices. |
graph * create_graph_selfloops | ( | uint | ) |
Creates a directed unlabeled graph whose only edges are self-loops.
lgraph * create_lgraph_noedges | ( | uint | size_graph, |
uint | size_alpha ) |
Creates a directed graph without edges.
size_graph | Number of vertices. |
size_alpha | Number of labels. |
Computes the direct product of two deterministic directed labeled graphs.
g1 | The first graph. |
g2 | The second graph. |
Computes the mirror of a complete deterministic directed labeled graph.
int dgraph_nb_edges | ( | dgraph * | G | ) |
Computes the number of edges in a complete deterministic directed labeled graph.
Computes a path from a given strating vertex to all other reachable vertices in a directed unlabeled graph.
UINT_MAX
is used to represent the non-defined edges).G | The graph. |
start | The starting vertex. |
dequeue * dgraph_search | ( | graph_stype | T, |
dgraph * | G, | ||
dequeue * | ini, | ||
bool * | alph, | ||
bool * | rest ) |
Search in a desterministic complete labeled graph. Reachable vertices are returned inside a dequeue sorted in increasing order.
T | The type of search that has to be used. |
G | The graph. |
ini | The starting set of vertices. |
alph | An array indexed by the labels. Used to restrict the edges that can be used. |
rest | An array indexed by the vertices. Used to restrict the list of reachable vertices. |
void dgraph_search_update | ( | graph_stype | T, |
dgraph * | G, | ||
dequeue * | ini, | ||
bool * | alph, | ||
bool * | visited ) |
Search in a desterministic complete labeled graph. A set of already visited vertices is taken as input. This set is updated by the search.
T | The type of search that has to be used. |
G | The graph. |
ini | The starting set of vertices. |
alph | An array indexed by the labels. Used to restrict the edges that can be used. |
visited | A set of already visited vertices. It is updated by the fucntion. |
Conversion of a deterministic labeled graph into a unlabeled graph.
dg | The labeled graph. |
Conversion of a deterministic labeled graph into a unlabeled graph. Restricted version.
dg | The labeled graph. |
alph | An array indexed by the labels. Used to restrict the edges that can be used. |
Conversion of a complete deterministic labeled graph into a standard labeled graph.
DG | The complete deterministic labeled graph. |
Computes the mirror of a directed unlabeled graph.
int graph_nb_edges | ( | graph * | G | ) |
Computes the number of edges in a directed unlabeled graph.
dequeue * graph_search | ( | graph_stype | T, |
graph * | G, | ||
dequeue * | ini, | ||
bool * | rest ) |
Searches in an unlabeled graph. Reachable vertices are returned inside a dequeue sorted in increasing order.
T | The type of search that has to be used. |
G | The graph. |
ini | The starting set of vertices. |
rest | An array indexed by the vertices. Used to restrict the list of reachable vertices. |
void graph_search_update | ( | graph_stype | T, |
graph * | G, | ||
dequeue * | ini, | ||
bool * | visited ) |
Searches in an unlabeled graph. A set of already visited vertices is taken as input. This set is updated by the search.
T | The type of search that has to be used. |
G | The graph. |
ini | The starting set of vertices. |
visited | A set of already visited vertices. It is updated by the fucntion. |
graph * ldgraphs_to_graph | ( | uint | ng, |
uint | nlg, | ||
uint | ndg, | ||
uint | n, | ||
... ) |
Merging an arbitrary number of graphs using the same set of vertices into a single unlabeled graph.
ng | Number of input unlabeled graphs. |
nlg | Number of input labeled graphs. |
ndg | Number of input complete deterministic labeled graphs. |
n | Total number of input graphs (sum of the three). |
... | The graphs. |
lgraph * ldgraphs_to_lgraph | ( | uint | nlg, |
uint | ndg, | ||
uint | n, | ||
... ) |
Merging an arbitrary number of labeled graphs using the same set of vertices into a single labeled graph.
nlg | Number of input labeled graphs. |
ndg | Number of input complete deterministic labeled graphs. |
n | Total number of input graphs (sum of the two). |
... | The graphs. |
Computes the mirror of a directed labeled graph.
int lgraph_nb_edges | ( | lgraph * | G | ) |
Computes the number of edges in a directed labeled graph.
Given a labeled graph, a list of vertices in this graph and a label, computes the list of all vertices connected to a vertex in the input list by an edge labeled by the input label.
G | The graph. |
start | The input list of vertices. |
a | The label. |
dequeue * lgraph_search | ( | graph_stype | T, |
lgraph * | G, | ||
dequeue * | ini, | ||
bool * | alph, | ||
bool * | rest ) |
Search in a labeled graph. Reachable vertices are returned inside a dequeue sorted in increasing order.
T | The type of search that has to be used. |
G | The graph. |
ini | The starting set of vertices. |
alph | An array indexed by the labels. Used to restrict the edges that can be used. |
rest | An array indexed by the vertices. Used to restrict the list of reachable vertices. |
void lgraph_search_update | ( | graph_stype | T, |
lgraph * | G, | ||
dequeue * | ini, | ||
bool * | alph, | ||
bool * | visited ) |
Search in a labeled graph. A set of already visited vertices is taken as input. This set is updated by the search.
T | The type of search that has to be used. |
G | The graph. |
ini | The starting set of vertices. |
alph | An array indexed by the labels. Used to restrict the edges that can be used. |
visited | A set of already visited vertices. It is updated by the fucntion. |
Conversion of a standard labeled graph into a unlabeled graph.
lg | The labeled graph. |
Conversion of a standard labeled graph into a unlabeled graph. Restricted version.
lg | The labeled graph. |
alph | An array indexed by the labels. Used to restrict the edges that can be used. |
graph * merge_graphs | ( | uint * | lag, |
uint | n, | ||
... ) |
Disjoint merge of an arbitrary number of unlabeled graphs.
lag | An array indexed by the input graphs. It is used to return the index of the first vertex of each graph in the merged graph. |
n | The number of graphs given as input. |
... | The graphs. |
lgraph * merge_lgraphs | ( | uint * | lag, |
uint | n, | ||
... ) |
Disjoint merge of an arbitrary number of labeled graphs.
lag | An array indexed by the input graphs. It is used to return the index of the first vertex of each graph in the merged graph. |
n | The number of graphs given as input. |
... | The graphs. |
dequeue * twin_dgraph_search | ( | graph_stype | T, |
dgraph * | G1, | ||
dgraph * | G2, | ||
dequeue * | ini, | ||
bool * | alph, | ||
bool * | rest ) |
Search in two deterministic complete labeled graphs (same set of vertices, same alphabet). Reachable vertices are returned inside a dequeue sorted in increasing order.
T | The type of search that has to be used. |
G1 | The first graph. |
G2 | The second graph. |
ini | The starting set of vertices. |
alph | An array indexed by the labels. Used to restrict the edges that can be used. |
rest | An array indexed by the vertices. Used to restrict the list of reachable vertices. |
void twin_dgraph_search_update | ( | graph_stype | T, |
dgraph * | G1, | ||
dgraph * | G2, | ||
dequeue * | ini, | ||
bool * | alph, | ||
bool * | visited ) |
Search in two deterministic complete labeled graphs (same set of vertices, same alphabet). A set of already visited vertices is taken as input. This set is updated by the search.
T | The type of search that has to be used. |
G1 | The first graph. |
G2 | The second graph. |
ini | The starting set of vertices. |
alph | An array indexed by the labels. Used to restrict the edges that can be used. |
visited | A set of already visited vertices. It is updated by the fucntion. |