Network Structure
This module provides a breief description of the decentralized network structure.
NetworkArchitecture
Decentralized network architecture
Description
This class is used to generate different network architectures. Here we add four different network architectures: fully connected, fully disconnected, circular network and star network.
Source code in src/desgld/network.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
circular_network()
Circular Network
Description
A circular network is a kind of network in which a particular node is connected to its left and right nodes only.
Parameters: |
|
---|
Returns: |
|
---|
Examples:
>>> w=NetworkArchitecture(size_w=5,random_seed=42)
>>> w=net.circular_network()
>>> print(w)
[[0.72162653 0.13918674 0. 0. 0.13918674]
[0.13918674 0.72162653 0.13918674 0. 0. ]
[0. 0.13918674 0.72162653 0.13918674 0. ]
[0. 0. 0.13918674 0.72162653 0.13918674]
[0.13918674 0. 0. 0.13918674 0.72162653]]
>>> print("Row sums:", np.sum(w, axis=0))
Row sums: [1. 1. 1. 1. 1.]
>>> print("Column sums:", np.sum(w, axis=1))
Column sums: [1. 1. 1. 1. 1.]
Source code in src/desgld/network.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
fully_connected()
Fully Connected Network
Description
A fully connected network is a kind of network in which all nodes are connected to all other nodes.
Parameters: |
|
---|
Examples:
>>> w=NetworkArchitecture(size_w=5,random_seed=42)
>>> w=w.fully_connected()
>>> print(w)
[[0.67811004 0.08047249 0.08047249 0.08047249 0.08047249]
[0.08047249 0.67811004 0.08047249 0.08047249 0.08047249]
[0.08047249 0.08047249 0.67811004 0.08047249 0.08047249]
[0.08047249 0.08047249 0.08047249 0.67811004 0.08047249]
[0.08047249 0.08047249 0.08047249 0.08047249 0.67811004]]
>>> print("Row sums:", np.sum(w, axis=0))
Row sums: [1. 1. 1. 1. 1.]
>>> print("Column sums:", np.sum(w, axis=1))
Column sums: [1. 1. 1. 1. 1.]
Source code in src/desgld/network.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
fully_disconnected()
Completely Disconnected Network
Description
A completely disconnected network is a kind of network in which all the nodes are disconnected from each other.
Returns: |
|
---|
Examples:
>>> net = NetworkArchitecture(size_w=6)
>>> w=net.circular()
>>> print(w)
[[1,0,0,0,0,0],
[0,1,0,0,0,0],
[0,0,1,0,0,0],
[0,0,0,1,0,0],
[0,0,0,0,1,0],
[0,0,0,0,0,1]]
Source code in src/desgld/network.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
star_network()
Star-like Connected Network
Description
A star-like network is a kind of network in which there is a central node and all other nodes are connected to the central node. However, the individual nodes are not connected to each other.
Parameters: |
|
---|
Returns: |
|
---|
Examples:
>>> w=NetworkArchitecture(size_w=5,random_seed=42)
>>> w=net.star_network()
>>> print(w)
[[0.71180893 0.07204777 0.07204777 0.07204777 0.07204777]
[0.07204777 0.92795223 0. 0. 0. ]
[0.07204777 0. 0.92795223 0. 0. ]
[0.07204777 0. 0. 0.92795223 0. ]
[0.07204777 0. 0. 0. 0.92795223]]
>>> print("Row sums:", np.sum(w, axis=0))
Row sums: [1. 1. 1. 1. 1.]
>>> print("Column sums:", np.sum(w, axis=1))
Column sums: [1. 1. 1. 1. 1.]
Source code in src/desgld/network.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|