20#include <unordered_map>
21#include <unordered_set>
35std::unordered_map<unsigned long, std::unordered_set<unsigned long> >
adj_list;
56 add_node(
static_cast<unsigned long>(g1));
58 add_edge(
static_cast<unsigned long>(g1),
static_cast<unsigned long>(g2),
true);
72void add_edge(
unsigned long src,
unsigned long tgt,
bool undirected=
true){
77 if(undirected)
adj_list[tgt].insert(src);
96std::unordered_set<unsigned long>
remove_node(
unsigned long node){
103 auto adjacency_list = std::move(it->second);
105 return adjacency_list;
124 unsigned long count = 0;
125 if (neigh1.size()>k-1 && neigh2.size()>k-1) {
126 for (
auto nn1:neigh1) {
127 for (
auto nn2:neigh2) {
152void fill(
const std::unordered_set<unsigned long>& nodes, \
153 bool undirected=
true){
205bool has_edge(
unsigned long src,
unsigned long tgt) {
209 retval = neigh.find(tgt)!=neigh.end();
222const std::unordered_set<unsigned long> &
get_neighbours(
unsigned long node)
const {
225 return (
adj_list.find(node))->second;
232const std::unordered_set<unsigned long> &
get_nodes()
const {
Boolean provenance circuit with support for knowledge compilation.
@ MULVAR
Auxiliary gate grouping all MULIN siblings.
@ UNDETERMINED
Placeholder gate whose type has not been set yet.
gate_t
Strongly-typed gate identifier.
Boolean circuit for provenance formula evaluation.
std::vector< gate_t > & getWires(gate_t g)
Return a mutable reference to the child-wire list of gate g.
gateType getGateType(gate_t g) const
Return the type of gate g.
std::vector< gate_t >::size_type getNbGates() const
Return the total number of gates in the circuit.
Mutable adjacency-list graph over unsigned-long node IDs.
void add_edge(unsigned long src, unsigned long tgt, bool undirected=true)
Add an edge between src and tgt.
void fill(const std::unordered_set< unsigned long > &nodes, bool undirected=true)
Add all missing edges within nodes (clique fill).
bool has_node(unsigned long node) const
Return true if node is present in the graph.
std::unordered_set< unsigned long > node_set
Set of all node IDs.
void add_node(unsigned long node)
Add node to the graph (no edges).
unsigned long number_edges() const
Return the number of edges in the graph.
const std::unordered_set< unsigned long > & get_nodes() const
Return the set of all node IDs in the graph.
void contract_edge(unsigned long src, unsigned long tgt)
Contract the edge (src, tgt) by merging tgt into src.
bool has_edge(unsigned long src, unsigned long tgt)
Return true if a directed edge from src to tgt exists.
bool has_neighbours(unsigned long node) const
Return true if node has any adjacent edges.
std::unordered_set< unsigned long > remove_node(unsigned long node)
Remove node and all its incident edges.
unsigned long num_edges
Current edge count.
const std::unordered_set< unsigned long > & get_neighbours(unsigned long node) const
Return the neighbour set of node.
bool neighbour_improved(unsigned k, unsigned long n1, unsigned long n2)
Test whether two nodes share more than k-1 common neighbours.
std::unordered_map< unsigned long, std::unordered_set< unsigned long > > adj_list
Adjacency lists.
Graph(const BooleanCircuit &bc)
Construct the primal graph of a BooleanCircuit.
unsigned long number_nodes() const
Return the number of nodes in the graph.