Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
load_digraph.H File Reference

Utilities for loading directed graphs from pipe-separated files. More...

#include <fstream>
#include <string>
#include <tpl_graph.H>
#include <topological_sort.H>
#include <Tarjan.H>
Include dependency graph for load_digraph.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::Equal_Node
 Functor to compare nodes by their ID. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Typedefs

using Aleph::Info_Nodo = std::pair< std::string, DynDlist< std::string > >
 Node payload: (id, fields) where fields come from the input row.
 
using Aleph::Nodo = Graph_Node< Info_Nodo >
 Node type for the digraph.
 
using Aleph::Arco = Graph_Arc< std::string >
 Arc type for the digraph (edge info is a string).
 
using Aleph::Digrafo = List_Digraph< Nodo, Arco >
 Digraph type used by the loader.
 

Functions

void Aleph::split (const std::string &text, const std::string &separators, DynDlist< std::string > &words)
 Split a text into tokens using a separator set.
 
Digrafo::NodeAleph::search_node (Digrafo &g, const std::string &s)
 Find or create a node by ID.
 
void Aleph::load_digraph (Digrafo &g, std::istream &nodes_input, std::istream &arcs_input)
 Load nodes and arcs from streams into the directed graph.
 
void Aleph::generate_dot_file (Digrafo &g, std::ostream &output)
 Generate a DOT representation of the digraph.
 

Variables

constexpr size_t Aleph::MIN_NODE_FIELDS = 7
 Minimum expected columns for a node record.
 
bool Aleph::with_power = false
 Configuration options for DOT file generation.
 
bool Aleph::with_nes = false
 If true, include NES percentage in node labels.
 
bool Aleph::only_num = false
 If true, show only the node number, not the full label.
 
bool Aleph::with_class = false
 If true, set node shapes based on class field.
 
size_t Aleph::font_size = 6
 Font size for the DOT output.
 
bool Aleph::vertical = true
 If true, use vertical layout (default).
 

Detailed Description

Utilities for loading directed graphs from pipe-separated files.

Provides functions to load a directed graph from two input streams: one for nodes (pipe-separated fields) and one for arcs (space/comma separated pairs of node IDs). Also provides DOT format export with optional styling based on node attributes.

Example: Loading graph from files
#include <load_digraph.H>
#include <fstream>
// Create node file (pipe-separated: id|name|value)
// nodes.txt:
// 1|Node_A|100
// 2|Node_B|200
// 3|Node_C|300
// Create arc file (space-separated: src dst)
// arcs.txt:
// 1 2
// 2 3
// 1 3
ifstream nodes_file("nodes.txt");
ifstream arcs_file("arcs.txt");
load_digraph(g, nodes_file, arcs_file);
// Graph now loaded with 3 nodes and 3 arcs
cout << "Nodes: " << g.get_num_nodes() << endl;
cout << "Arcs: " << g.get_num_arcs() << endl;
void load_digraph(Digrafo &g, std::istream &nodes_input, std::istream &arcs_input)
Load nodes and arcs from streams into the directed graph.
Utilities for loading directed graphs from pipe-separated files.
List_Digraph< Nodo, Arco > Digrafo
Digraph type used by the loader.
Example: Exporting to DOT format
ofstream dot_file("graph.dot");
save_in_dot(g, dot_file);
// Creates DOT file for visualization with Graphviz
Author
Leandro Rabindranath León

Definition in file load_digraph.H.