set up complete graph if n<=d

If the number of nodes in a channel is smaller or equal than the
requested degree, a fully connected graph is used. For n>d, a random
d-regular graph is set up. (For n=d+1, the two are the same.)

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-02-15 02:50:03 +01:00
parent 8f2052e1ac
commit 763ebfe136
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
1 changed files with 13 additions and 6 deletions

View File

@ -53,8 +53,13 @@ class Simulator:
for id in range(self.shape.blockSize): for id in range(self.shape.blockSize):
if (len(rowChannels[id]) < self.shape.netDegree): # If the number of nodes in a channel is smaller or equal to the
self.logger.error("Graph degree higher than %d" % len(rowChannels[id]), extra=self.format) # requested degree, a fully connected graph is used. For n>d, a random
# d-regular graph is set up. (For n=d+1, the two are the same.)
if (len(rowChannels[id]) <= self.shape.netDegree):
self.logger.debug("Graph fully connected with degree %d !" % (len(rowChannels[id]) - 1), extra=self.format)
G = nx.complete_graph(len(rowChannels[id]))
else:
G = nx.random_regular_graph(self.shape.netDegree, len(rowChannels[id])) G = nx.random_regular_graph(self.shape.netDegree, len(rowChannels[id]))
if not nx.is_connected(G): if not nx.is_connected(G):
self.logger.error("Graph not connected for row %d !" % id, extra=self.format) self.logger.error("Graph not connected for row %d !" % id, extra=self.format)
@ -64,8 +69,10 @@ class Simulator:
val1.rowNeighbors[id].update({val2.ID : Neighbor(val2, self.shape.blockSize)}) val1.rowNeighbors[id].update({val2.ID : Neighbor(val2, self.shape.blockSize)})
val2.rowNeighbors[id].update({val1.ID : Neighbor(val1, self.shape.blockSize)}) val2.rowNeighbors[id].update({val1.ID : Neighbor(val1, self.shape.blockSize)})
if (len(columnChannels[id]) < self.shape.netDegree): if (len(columnChannels[id]) <= self.shape.netDegree):
self.logger.error("Graph degree higher than %d" % len(columnChannels[id]), extra=self.format) self.logger.debug("Graph fully connected with degree %d !" % (len(columnChannels[id]) - 1), extra=self.format)
G = nx.complete_graph(len(columnChannels[id]))
else:
G = nx.random_regular_graph(self.shape.netDegree, len(columnChannels[id])) G = nx.random_regular_graph(self.shape.netDegree, len(columnChannels[id]))
if not nx.is_connected(G): if not nx.is_connected(G):
self.logger.error("Graph not connected for column %d !" % id, extra=self.format) self.logger.error("Graph not connected for column %d !" % id, extra=self.format)