NetworkEdge
Namespace: CONNECTIVITYLIB · Library: Connectivity Library · Source: connectivity/network/networkedge.h
#include <connectivity/networkedge.h>
class CONNECTIVITYLIB::NetworkEdge
Directed weighted edge connecting two NetworkNode instances.
Holds the start- and end-node IDs, the full per-frequency weight matrix delivered by the metric, an active/inactive flag honoured by the thresholded views on Network, and the [iStartWeightBin, iEndWeightBin) window that reduces the matrix to the scalar weight used for thresholding and rendering. For symmetric metrics the directionality is purely a storage convention.
Weighted, directional edge in a Network; carries per-frequency weights plus a band-averaged scalar.
Network network("manual");
for (int i = 0; i < 3; ++i) {
network.append(NetworkNode::SPtr(new NetworkNode(i, positions.row(i))));
}
const QList<QPair<int, int>> pairs = {{0, 1}, {1, 2}};
const QList<double> weights = {0.9, 0.2};
for (int k = 0; k < pairs.size(); ++k) {
MatrixXd perBin = MatrixXd::Constant(1, 1, weights[k]);
NetworkEdge::SPtr edge(new NetworkEdge(pairs[k].first, pairs[k].second, perBin));
network.getNodeAt(pairs[k].first)->append(edge);
network.getNodeAt(pairs[k].second)->append(edge);
network.append(edge);
}
Public Methods
NetworkEdge(iStartNodeID, iEndNodeID, matWeight, bIsActive, iStartWeightBin, iEndWeightBin)
Constructs a NetworkEdge object.
Parameters:
-
iStartNodeID : int The start node id of the edge.
-
iEndNodeID : int The end node id of the edge.
-
matWeight : const Eigen::MatrixXd & The edge weight.
-
bIsActive : bool The active flag of this edge. Default is true.
-
iStartWeightBin : int The bin index to start avergaing from. Default is -1 which means an average over all weights.
-
iEndWeightBin : int The bin index to end avergaing to. Default is -1 which means an average over all weights.
getStartNodeID()
Returns the start node of this edge.
Returns:
- int — The start node of the edge.
getEndNodeID()
Returns the end node of this edge.
Returns:
- int — The end node of the edge.
setActive(bActiveFlag)
Sets the activity flag of this edge.
Parameters:
- bActiveFlag : bool The new activity flag of this edge.
isActive()
Returns the activity flag of this edge.
Returns:
- bool — The current activity flag of this edge.
getWeight()
Returns the edge weight.
The weights are averaged between the specified bin indeces and their corresponding tapers.
Returns:
- double — The current edge weight.
getMatrixWeight()
Returns the edge weight non-averaged in form of a matrix.
Returns:
- Eigen::MatrixXd — The current edge weight matrix.
setWeight(dAveragedWeight)
Set the averaged edge weight.
Parameters:
- dAveragedWeight : double The new weight.
calculateAveragedWeight()
Calculates the edge weight based on the currently set min/max frequency bins.
setFrequencyBins(minMaxFreqBins)
Sets the frequency bins to average from/to.
Parameters:
- minMaxFreqBins : const QPair< int, int > & The new lower/upper bin to average from/to.
getFrequencyBins()
Returns the current frequency bins to average from/to.
Returns:
- const QPair< int, int > & — The current upper/lower bin to average from/to.
Example
- Start here: ex_connectivity_metrics — Connectivity metrics on synthetic data with a known coupling.
- Full source:
src/examples/ex_connectivity_metrics/main.cpp - Build target:
ex_connectivity_metrics(runs under CTest)