Skip to main content

NetworkEdge

Namespace: CONNECTIVITYLIB  ·  Library: Connectivity Library

#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.

src/examples/ex_connectivity_metrics/main.cpp
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​

Used in examples​

ex_connectivity_metrics​

Connectivity metrics on synthetic data with a known coupling.

src/examples/ex_connectivity_metrics/main.cpp, line 115
for (const NetworkEdge::SPtr& edge : network.getFullEdges()) {
if (edge->getStartNodeID() == start && edge->getEndNodeID() == end) {
return edge->getWeight();
}
}
return -1.0;
}

ex_disp3d_scene​

Disp3D scene data: sensor-to-surface interpolation, electrodes, MRI slices, video overlay and layers.

src/examples/ex_disp3d_scene/main.cpp, line 280
NetworkEdge::SPtr edge(new NetworkEdge(links[k].first, links[k].second, MatrixXd::Constant(1, 1, strengths[k])));
graph.getNodeAt(links[k].first)->append(edge);
graph.getNodeAt(links[k].second)->append(edge);
graph.append(edge);
}
NetworkObject networkGlyphs;
networkGlyphs.load(graph, "Viridis"); // spheres for nodes, cylinders for edges
const int edgesAll = networkGlyphs.edgeInstanceCount();
networkGlyphs.setThreshold(0.5); // keep only the strong 0-1 link
ok &= expect(edgesAll == 2 && networkGlyphs.edgeInstanceCount() == 1 && networkGlyphs.nodeInstanceCount() == 2,
"NetworkObject: thresholding at 0.5 leaves one edge and its two nodes");

Authors of this file​