nns.c  1.0.1
Nanowire Network simulator
components.h File Reference

Contains utility functions to work with connected components of a Nanowire Network. The only function that is supposed to be used directly by a user is split_components. More...

#include "device/network.h"
#include "device/component.h"

Go to the source code of this file.

Functions

int map_components (const datasheet ds, const network_topology nt, int n2c[])
 Given a network topology and its corresponding datasheet, generate an array containing for each node the index of the parent connected component and return the number of connected components discovered. More...
 
void group_nanowires (const datasheet ds, network_topology nt, int n2c[], int cc_count)
 Sort the Ws and Js arrays of nt according to the index of the connected component each entry belongs to. The index is specified by the n2c array. Once nt is sorted, also the entries of the n2c arrays are corrected to match those of the new nt. E.g.: More...
 
connected_componentsplit_components (const datasheet ds, const network_topology nt, int n2c[], int cc_count)
 Create cc_count connected components referencing the sub-arrays of ns containing the data belonging to them. Since the wires and the junctions are ordered according to the CC index, it is enough to know the starting point of the arrays (i.e., ws_skip and js_skip) and their length (i.e., ws_count and js_count). Additionally, calculate and save the index of the junctions in the CC-specific adjacency matrix (see Is array). More...
 

Detailed Description

Contains utility functions to work with connected components of a Nanowire Network. The only function that is supposed to be used directly by a user is split_components.

Function Documentation

◆ group_nanowires()

void group_nanowires ( const datasheet  ds,
network_topology  nt,
int  n2c[],
int  cc_count 
)

Sort the Ws and Js arrays of nt according to the index of the connected component each entry belongs to. The index is specified by the n2c array. Once nt is sorted, also the entries of the n2c arrays are corrected to match those of the new nt. E.g.:

n2c = [0, 1, 0, 2, 1]
ws = [a, b, c, d, e]
|
\/
ws = [a, c, b, e, d]
Parameters
[in]dsThe datasheet describing the Nanowire Network.
[in,out]ntThe topology of the Nanowire Network to sort. Ws will be sort according to the CC index, original first wire index, and original second wire index. Js will be sorted according to the new indexes of the wires.
[in,out]n2cAn array of length 'ds.wires_count' containing for each entry the index of the parent connected component. After the function call it will contain the entries sorted to match the Ws wires.
[in]cc_countThe number of connected components discovered in the NN.

◆ map_components()

int map_components ( const datasheet  ds,
const network_topology  nt,
int  n2c[] 
)

Given a network topology and its corresponding datasheet, generate an array containing for each node the index of the parent connected component and return the number of connected components discovered.

Parameters
[in]dsThe datasheet describing the Nanowire Network.
[in]ntThe topology of the Nanowire Network.
[out]n2cAn array of length 'ds.wires_count' containing for each entry the index of the parent connected component.
Returns
The number of connected components discovered in the NN.

◆ split_components()

connected_component* split_components ( const datasheet  ds,
const network_topology  nt,
int  n2c[],
int  cc_count 
)

Create cc_count connected components referencing the sub-arrays of ns containing the data belonging to them. Since the wires and the junctions are ordered according to the CC index, it is enough to know the starting point of the arrays (i.e., ws_skip and js_skip) and their length (i.e., ws_count and js_count). Additionally, calculate and save the index of the junctions in the CC-specific adjacency matrix (see Is array).

Parameters
[in]dsThe datasheet describing the Nanowire Network.
[in]ntThe topology of the Nanowire Network.
[in]n2cAn array of length 'ds.wires_count' containing for each entry the index of the parent connected component.
[in]cc_countThe number of connected components discovered in the NN.
Returns
The array of cc_count initialized connected components.