Extending/scaling graph network based on independent nodes using NetworkX - python

I have two separate lists of nodes and stations. Each list consists of Node (or station) ID, x-coordinate, and y-coordinate. I pick up a random set of nodes and connect them to generate a graph network using NetworkX based on a certain distance between them. I select a random set of stations. I have shared the data and code at Data and Code
Now, I want to extend the graph network in a way that each edge should be within a certain distance from the station. I want to keep the shape (topology) of the initial network as it is but want to zoom (or scale/extend) the network to make it close to the stations. I am not sure how can I extend the graph to meet the aforementioned conditions/constraints. The stations can be regarded as forming an overlay network and the base network is being extended based on this overlay network. Here is a figure to show the desired network. Any help in this regard is very much appreciated.
Network Diagram

Related

Looking for python packages that can calculate nodes/region/edges while respecting X,Y coordinates of nodes

I have a list of cities (nodes) plotted in a 2D plane each given by an X,Y coordinate.
I now want to add roads (edges) to it, but the roads cannot intersect. I want to create the most number of roads possible. By count, not by total length.
In more general graph theory parlance, I think I want the maximum number of edges (or regions?? maybe it's the same thing), where edges do not intersect in 2-dimensions, for a given set of Nodes at X,Y points.
In a brief view of NetworkX, it seems that they generate Graphs by making "nodes" but nodes can be "anywhere" and cannot force nodes to be at a certain location with respect to each other (they have abstracted too far!).
Edit: networkx add_node with specific position
suggests that you can plot them in a given location. #Stef thanks!!
Am i thinking about the problem correctly?
Can I visualize using some python package my Nodes/edges, where this package can automatically calculate the proper edges given a set of nodes?
Is automatically finding the maximum number of non-intersecting edges a thing (and what is this called so I can find out more about it?)
Very possibly similar to this question, but this question wasn't really answered and from 8 years ago (Algorithm for finding minimal cycle basis of planar graph)

Vertices are double of edges

I am trying to detect the communities in a temporal network, that is, i want to detect communities at different time stamp and for that I am using Dataframe for filtering the data according to time.
For time, t=0, i want to plot the graph, I am using matplotlib for this purpose and also I am using igraph for the algorithms.
However, if I have n edges it is using 2n nodes when nodes are few. When I try to take only the unique vertices, it is showing the error vertex id invalid and if I let the code take 2n nodes then it is taking the vertices not even there in the time stamp. The graph formed is not meaningful as well

Place a "root" node in an undirected graph

I'm trying to model computer networks in Python using Networkx with the built-in Barabasi-Albert graph generator. My understanding is that this better represents a real network.
I want to randomly select a node as a entry/exist point for an attacker and visualize it with matplotlib. However, this "random" node can be place pretty much anywhere in the layout (I'm currently using the spring layout). This looks a little weird sometimes as the selected node could be right in the middle of the visualization, as if the entry/exit node is from within the network vs the network edge.
While a case could be made that this could represent insider threats, that's not something I would like to show at this time.
Is there an easy way I can position the node so that it's on the "exterior" of the graph? Or perhaps "pick" one of the nodes on the "exterior" as this entry/exit?

Positioning networkx nodes by shared node attributes

Is it possible to position nodes in a networkx graph so that nodes sharing a certain (single) attribute are clustered near each other?
For example, if the nodes represent people and each has an attribute 'age', how can I make it so that people of the same age are near each other when I draw the graph? Is this possible?
You can specify the x,y coordinates of each node. So if you have some idea on how you want it to look it can be programmed. You could try a spring layout but this isn't going to be hit or miss, it's going to be more misses. The way to attempt it is by connecting the nodes of the same data to each other. (people of the same age have one or more edges between them)
The only way I see this working well with large amounts of data is using a tool called Gephi to manipulate by hand based on node data etc... it's like a photoshop of network graphs.
I would suggest yet another approach. Create an extra attribute for your nodes that corresponds to a range of values of the attribute you want to use for the grouping. For example, if your attribute is age, then create ranges 18-30, 31-40, etc. Save the result in GraphML format and load the network with NodeXL (which is not free anymore but you could buy it for a small fee)
In NodeXL you can group the nodes by some attribute and it lays out the different groups so that nodes belonging to the same group are laid out close to each other. You can also choose how nodes in a group are laid out, from a list of layout options)

An algorithm to add nodes in a wireless network to obtain connected coverage

I basically have already put Nodes with a specific location and power transmitted from each in a 50m x 50m room and one of the nodes being the Server node that I want every node to connect to in both ways(Directions).
Each node has a circle radius that represents it's coverage around it.
I want to create an algorithm to place extra nodes to the room so that I can obtain a 1 Strongly connected component between all the already existing nodes and the added extra nodes.
I've searched the spanning tree algorithm and new the implementation of them in python but I don't yet know an algorithm or a pseudo code that I can implement to achieve that.
Does anyone know an algorithm or a name of one or anything that can help me implement it?
Thanks in advance

Categories