10#include <unordered_set>
11#include "Escape/Graph.h"
56 if (node_id >= 0 &&
static_cast<size_t>(node_id) <
fast_node_to_idx.size()) {
64 if (node_id >= 0 &&
static_cast<size_t>(node_id) <
fast_labels.size()) {
78 const std::vector<std::pair<int, int>>& edges);
81 int degree(
int node_id)
const;
83 bool hasEdge(
int u,
int v)
const;
94 void build(
const std::vector<int>& vertex_ids,
const std::vector<int>& vertex_labels,
95 const std::vector<std::pair<int, int>>& edges);
int get_node_idx(int node_id) const
Internal index of a node ID, or -1 if the vertex is not in this graph.
Definition AppGraph.h:55
std::shared_ptr< const LabelIndex > label_index
Built by buildLabelIndex() (the data graph's); null otherwise. Shared by copies.
Definition AppGraph.h:43
~AppGraph()
Definition AppGraph.cpp:9
void copy_from(const AppGraph &other)
Definition AppGraph.cpp:51
bool readFromFile(const std::string &filepath)
Reads a graph in the "t / v / e" text format: a line v <id> <label> [...] per vertex and a line e <u>...
Definition AppGraph.cpp:95
bool buildFromLabelsAndEdges(const std::vector< int > &vertex_labels, const std::vector< std::pair< int, int > > &edges)
Builds the graph from memory.
Definition AppGraph.cpp:130
void build(const std::vector< int > &vertex_ids, const std::vector< int > &vertex_labels, const std::vector< std::pair< int, int > > &edges)
Definition AppGraph.cpp:141
Escape::CGraph * c_graph
Adjacency in CSR form, indexed by internal index; neighbour lists are sorted. Owned.
Definition AppGraph.h:35
bool hasEdge(int u, int v) const
Whether node IDs u and v are adjacent in this graph.
Definition AppGraph.cpp:220
std::vector< int > getNeighbors(int node_id) const
Neighbours of a node ID, as node IDs.
Definition AppGraph.cpp:231
std::vector< int > fast_labels
Node ID -> label, or -1 if the vertex is not in this graph.
Definition AppGraph.h:41
std::vector< int > fast_node_to_idx
Node ID -> internal index, or -1 if the vertex is not in this graph.
Definition AppGraph.h:39
std::vector< int > original_node_ids
Node IDs in ascending order; the position of an ID is its internal index.
Definition AppGraph.h:37
static AppGraph createSubgraph(const AppGraph &original, const std::unordered_set< int > &node_subset)
The subgraph of original induced by node_subset (node IDs): those vertices and every edge of original...
Definition AppGraph.cpp:245
void clear()
Definition AppGraph.cpp:13
void buildLabelIndex()
Builds label_index.
Definition AppGraph.cpp:188
int degree(int node_id) const
Degree of a node ID in this graph (0 if absent).
Definition AppGraph.cpp:214
int get_label_fast(int node_id) const
Label of a node ID, or -1 if the vertex is not in this graph.
Definition AppGraph.h:63
AppGraph & operator=(const AppGraph &other)
Definition AppGraph.cpp:26
A vertex-labelled, undirected graph: the pattern, the data graph, or an induced subgraph of the data ...
Definition AppGraph.h:23
std::vector< size_t > nlf_offsets
Vertex v has nlf_count[i] neighbours of label nlf_label[i], for i in [nlf_offsets[v],...
Definition AppGraph.h:28
std::vector< int > nlf_label
Definition AppGraph.h:29
std::vector< int > nlf_count
Definition AppGraph.h:29
int max_label
Largest label, -1 if the graph is empty.
Definition AppGraph.h:25