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

Defines the structure and operations for connected components in a Nanowire Network. More...

Go to the source code of this file.

Classes

struct  connected_component
 Connected component of the Nanowire Network. It contains all the information needed to identify the nanowires and junctions in it. Additionally, it contains the index of the junctions in the CC-specific adjacency matrix. More...
 

Functions

int cccmp (const void *e1, const void *e2)
 Compare two connected components according to their size and potentially the number of junctions. More...
 
connected_component copy_component (const connected_component cc)
 Create a deep copy of a connected component. More...
 
void destroy_component (connected_component cc)
 Destroy a connected component by freeing its pointers (i.e., Is). The array to be freed must have been allocated in the heap. More...
 

Detailed Description

Defines the structure and operations for connected components in a Nanowire Network.

This file contains the definition of the connected_component struct, which represents a connected component of the Nanowire Network and identify its belonging nanowires and junctions. Additionally, it provides functions to compare, copy, and destroy connected components.

Note
The connected_component uses dynamically allocated memory that must be managed using the provided functions.

Function Documentation

◆ cccmp()

int cccmp ( const void *  e1,
const void *  e2 
)

Compare two connected components according to their size and potentially the number of junctions.

Parameters
[in]e1Pointer to the first element to compare.
[in]e2Pointer to the second element to compare.
Returns
0 if the connected components have the same number of wires and junctions; > 0 if e1 has more wires (or in case of equality junctions) than e2; < 0 otherwise.

◆ copy_component()

connected_component copy_component ( const connected_component  cc)

Create a deep copy of a connected component.

Parameters
[in]ccThe connected component to copy.
Returns
The deep copy of the connected component.

◆ destroy_component()

void destroy_component ( connected_component  cc)

Destroy a connected component by freeing its pointers (i.e., Is). The array to be freed must have been allocated in the heap.

Parameters
[in,out]ccThe connected component to destroy.