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

Three creative scenarios demonstrating Mo's algorithm on trees. More...

#include <tpl_mo_on_trees.H>
#include <tpl_graph.H>
#include <tpl_sgraph.H>
#include <tpl_agraph.H>
#include <tpl_dynListStack.H>
#include <tpl_dynSetHash.H>
#include <cassert>
#include <cstdio>
Include dependency graph for mo_on_trees_example.cc:

Go to the source code of this file.

Functions

template<class GT >
static size_t brute_subtree_distinct (const GT &g, typename GT::Node *tree_root, typename GT::Node *subtree_root)
 
template<class GT >
static size_t brute_path_distinct (const GT &g, typename GT::Node *root, typename GT::Node *u, typename GT::Node *v)
 
static void rainforest_biodiversity ()
 
static void network_latency ()
 
static void org_chart ()
 
static void filesystem_inodes ()
 
int main ()
 

Detailed Description

Three creative scenarios demonstrating Mo's algorithm on trees.

SCENARIO 1 — "Rainforest Biodiversity" (List_Graph, subtree queries)

A botanist catalogues plant species in a hierarchical forest canopy. Each node represents a canopy section labelled by its dominant species. Subtree queries count how many distinct species appear in each section and all sub-sections beneath it.

SCENARIO 2 — "Network Latency Analysis" (List_SGraph, path queries)

A tree-shaped data-centre network has routers labelled by latency class. Path queries between pairs of routers count the number of distinct latency classes along the route.

SCENARIO 3 — "Corporate Org Chart" (Array_Graph, path + subtree)

An org chart tree stores department IDs. Subtree queries find distinct departments under a VP; path queries count distinct departments between two employees. Demonstrates Array_Graph.

Definition in file mo_on_trees_example.cc.

Function Documentation

◆ brute_path_distinct()

◆ brute_subtree_distinct()

◆ filesystem_inodes()

static void filesystem_inodes ( )
static

Definition at line 386 of file mo_on_trees_example.cc.

References Aleph::destroy_tree(), Aleph::divide_and_conquer_partition_dp(), and root().

Referenced by main().

◆ main()

◆ network_latency()

◆ org_chart()

◆ rainforest_biodiversity()