Class Topology

Class Documentation

class netuit::Topology

Public Types

using node_id_t = size_t
using edge_id_t = size_t
using value_type = TopoNode

Public Functions

Topology() = default
template<typename ...Args>
Topology(Args&&... args)
Topology(std::istream &is)
topology_t::const_iterator begin() const noexcept
topology_t::const_iterator end() const noexcept
topology_t::const_iterator cbegin() const noexcept
topology_t::const_iterator cend() const noexcept
void push_back(const TopoNode &node)

Insert node in Topology.

Parameters
  • [in] node: Node to insert.

void push_back(TopoNode &&node)

Insert node in Topology.

Parameters
  • [in] node: Node to insert.

template<typename ...Args>
void emplace_back(Args&&... args)

Emplace node in Topology.

Parameters
  • [in] args: Arguments of node to emplace.

size_t GetSize() const noexcept

Returns number of nodes in topology

Return

number of nodes in topology

const TopoNode &operator[](size_t n) const

Return nth node in topology

Return

const ref to nth node

void SetMap(const std::unordered_map<node_id_t, node_id_t> &map)

Sets map of node IDs to Canonical node IDs.

Parameters
  • [in] map: Map of node IDs to Canonical node IDs

node_id_t GetCanonicalNodeID(const node_id_t node_id) const

A Canonical node ID is the ID of the node in the original subtopology. After GetSubTopology is called, nodes of that topology get a new ID, but their Canonical ID stays the same. This provides a way to trace back nodes to the original, parent topology.

Return

Canonical ID of node.

Parameters
  • node_id[in]: ID of node to get Canonical ID of.

auto AsCSR() const

Return Compressed Sparse Row (CSR) representation of topology. For more info, see: https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_(CSR,_CRS_or_Yale_format)

Return

std::pair of vectors of int32_t

void PrintEdgeList(std::ostream &os = std::cout) const noexcept

Outputs this Topology’s Edge list. This format stores node IDs with their respective edge IDs. For more info, see https://networkx.github.io/documentation/stable/reference/readwrite/edgelist.html

Parameters
  • [out] os: Stream to output Edge list to.

void PrintAdjacencyList(std::ostream &os = std::cout) const noexcept

Outputs this Topology’s Adjacency list. This format stores node IDs with the IDs of nodes they are connected to. For more info, see https://networkx.github.io/documentation/stable/reference/readwrite/adjlist.html

Parameters
  • [out] os: Stream to output Adjacency list to.

void PrintPartition(const std::vector<int> &partition, std::ostream &os = std::cout) const
Topology GetSubTopology(const std::unordered_set<size_t> &node_ids) const

Returns a subtopology made up of all the nodes passed onto it, based on the topology it was called on.

Return

Subtopology from Node IDs.

Parameters
  • [in] node_ids: Node IDs of nodes to make subtopology out of.

  • [in] translator: Map of Node IDs to Canonical Node IDs.

std::string ToString() const noexcept

Returns this Topology’s adjacency list as a string.

Return

String describing topology