Arrange nodes in ns2 - networking

I need to arrange 100 nodes in a hexagonal shape in my tcl script. My simulation is wireless (dsr protocol). How can I do this? Which is the best size of the grid? I thought 3000x3000.
Thank you.

The simplest way is to build the network graphically .. you can use nsg tool to build the network and generate the tcl code very easily
http://www.nsnam.com/2013/04/ns2-scenario-generator.html
first you must determine the transition range of nodes, put required number of node-> get network size , or you can compute it mathematically using transmition range and hexagon aria
https://en.wikipedia.org/wiki/Hexagon
If you plan to use nsg to draw a regular hexagon use this simple trick:
if the transmition range is equal to 300 m then make it 250 m
put first node in the center of the network.
put two nodes in the border of first node coverage aria.
put other nodes in the 4 Intersection of coverage area o previous 3 nodes.
repeat previous steps for other hexagons.
return the transmition range to its correct value (300 m).

Related

Best data structure & packages to represent geometric units on a grid

I want to write a program with 'geometry automata'. I'd like it to be a companion to a book on artistic designs. There will be different units, like the 'four petal unit' and 'six petal unit' shown below, and users and choose rulesets to draw unique patterns onto the units:
I don't know what the best data structure to use for this project is. I also don't know if similar things have been done and if so, using what packages or languages. I'm willing to learn anything.
All I know right now is 2D arrays to represent a grid of units. I'm also having trouble mathematically partitioning the 'subunits'. I can see myself just overlapping a bunch of unit circle formulas and shrinking the x/y domains (cartesian system). I can also see myself representing the curve from one unit to another (radians).
Any help would be appreciated.
Thanks!!
I can't guarantee that this is the most efficient solution, but it is a solution so should get you started.
It seems that a graph (vertices with edges) is a natural way to encode this grid. Each node has 4 or 6 neighbours (the number of neighbours matches the number of petals). Each node has 8 or 12 edges, two for each neighbour.
Each vertex has an (x,y) co-ordinate, for example the first row in in the left image, starting from the left is at location (1,0), the next node to its right is (3,0). The first node on the second row is (0,1). This can let you make sure they get plotted correctly, but otherwise the co-ordinate doesn't have much to do with it.
The trouble comes from having two different edges to each neighbour, each aligned with a different circle. You could identify them with the centres of their circles, or you could just call one "upper" and the other "lower".
This structure lets you follow edges easily, and can be stored sparsely if necessary in a hash set (keyed by co-ordinate), or linked list.
Data structure:
The vertices can naturally be stored as a 2-dimensional array (row, column), with the special characteristic that every second column has a horizontal offset.
Each vertex has a set of possible connections to those vertices to its right (upper-right, right, or lower right). The set of possible connections depends on the grid. Whether a connection should be displayed as a thin or a thick line can be represented as a single bit, so all possible connections for the vertex could be packed into a single byte (more compact than a boolean array). For your 4-petal variant, only 4 bits need storing; for the 6-petal variant you need to store 6 bits.
That means your data structure should be a 2-dimensional array of bytes.
Package:
Anything you like that allows drawing and mouse/touch interaction. Drawing the connections is pretty straightforward; you could either draw arcs with SVG or you could even use a set of PNG sprites for different connection bit-patterns (the sprites having partial transparency so as not to obscure other connections).

Optimal distance between clusters in space

I start working at a project for an CNC machine and I am struggling to make an optimal algorithm to cut different parts of some type of material.
The problem can be put in this way: I have a set of clusters. Each cluster represent the form I wish to cut. I need to find a way to move the cutting edge to visit all clusters but only one time for each cluster. Also the path that I choose needs to be absolutely optimal. I also need to do this for around 5.000 edges. As an input I have a matrix of all the distances from each edge to others. The Dijkstra or Froyd algorithm can not handle so many edges. I tried the single-linkage method with the Slink optimization but it fails in most of the possible cases.
This is an example of what I want to do. The red lines form the clusters and the blue lines represent the path of the cutting edge. I need to find the shortest path from a random cluster to each other cluster visiting only once the most suitable edge of each cluster. How to do this?

Super position of small network over big network

I am working on PPI network and for the network plot I am using Gephi and rgexf package. In my network there are 9453 no. of vertices and 36888 connections. So, when plot the network on gephi we can't analyse anything, so I plot only top 50 nodes network. Now I want to highlight that 50 node's network over the top 100 nodes network. Here the top means the nodes which has highest degree. So is there any way to do it?
This the plot for top 50 nodes, there is one node which is not connected to any of the node in top50:
I am struggling from few days.
UPDATE - I updated the descriptions
Ok so this is not totally trivial but not straightforward either. I have created a random network with 500 nodes to show you an example.
After you load your network with Gephi you need at least to run the Average degree from the statistics.
You then go to the Filters section, select Attributes>Range>In-degree, double-click and press the Filter button (Note: In your case you should just see Degree but the rest still apply)
Move the slider to the right so that in the Context panel the number of remaining nodes reaches ~50
Here is how it looks for me
COLORING:
While you keep the Filter button pressed you can apply a different color to the filtered nodes. In my case I went in Ranking>Nodes selected InDegree and applied a green color. Note that you can also select Degree to get the effect you want. The respective panel looks like that:
This colors only the filtered nodes. Alternatively, you can apply the node brush but then it becomes a bit dull :). There is a 3rd option but I leave it as an exercise :).
The final graph looks like that for me.
Programmatically you could do something similar in igraph. You can select the nodes with top-50 indegrees, assign them a color, assign all the rest a different color and export to GraphML.
I hope it helped.
What you can do is importing the network to gephi ASIS and compute degree centrality, this will generate a variable with the degree of each vertex in the graph. After that you can use the filter tool (as illustrated in this presentation http://www.clementlevallois.net/gephi/tuto/en/gephi_advanced%20functions_en.pdf) to restrict the number of vertices to work with using the degree variable. That's the easy way.
Alternatively, you can calculate each node's degree using either igraph or sna packages, and include such as an attribute of your network in the write.gexf function.

Clustering in Gephi (Louvain Method)

I have started to work with gephi to help me display a dataset.
The dataset contains:
tags (terms for a certain picture) as nodes
Normalized Google Similarity Distance between those tags as edges with a weight (between 0 und 1)
Every tag is connected to every other tag, as long as they both belong to the same picture. So I have one cluster of nodes and edges for every picture.
I have now imported this dataset to gephi in the following format:
nodes: id, label
edges: target, source, weight (between 0 and 1)
Like 500 nodes and 6000 edges.
My problem now is that after importing all those nodes and edges the graph looks kind of bunched with no real order. Every cluster of every picture is mixed into other clusters of other pictures.
Now using Modularity as Partition algorithm (which should use the Louvain method) the graph is getting colored, each color represent a picture. Now I can split this mess, using the Force Atlas 2 Layout.
I now have a colored graph with something like 15 clusters (every cluster represent 1 picture)
Now I want to cluster those clusters again using tags (nodes) according to their Normalized google distance (weight of the edges), which should then be tags which are somewhat equal in their meaning.
I hope you guys understand what I want to accomplish.
I can also upload a picture to clarify it.
Thanks a lot
I don't think you can do that with the standard version of Gephi. You would need to develop a plugin to implement the very last step of your process.
Gephi is good for visualizing and browsing graphs, but (for now) there are more complete tools when it comes to processing topological properties. for instance, the igraph library (available in C, R and python) might be more appropriate for you. And note that you can use a file format compatible with both Gephi and igraph, which allows you to use both tools on the same data.
I was able to solve my problem. I had to import every one of these 15 clusters on their own. In this way i could use the Modularity method on just those few.

Graph Drawing With Weighted Edges

I'm looking to build an algorithm (or reuse one) that organizes nodes and edges on a 2 dimensional canvas where edges can have corresponding weights.
Any starting material and info would be helpful.
What would the weights do to affect their placement on your canvas?
That being said, you might want to look into graphviz and, more specifically, the DOT language, which organizes nodes on a canvas.
Many graph visualization frameworks use a force-based simulation, in which all nodes exert a repulsive force against each other (with their mass being their size), and edges exert tension on the nodes they connect. This creates aesthetically-arranged graph visualizations.
Although again, I'm not sure where you want node "weights" to come into play. Do you want weighted nodes to be more in the center? To be larger? More further apart?
Many graph/network layout algorithms are implicitly capable of handling weighted networks, but you may need to do some pre-processing and tweaks to the implementation to get it to work. Usually the first step is to determine if your weights represent "similarities" (usually interpreted to mean that stronger weights should place nodes closer togeter) or "dissimilarities" (stronger weights = father apart). The most common case is the former, so you will need to translate them to dissimilarities, often done by subtracting each edge value from the maximum observed edge value in the network. The matrix of dissimilarity values for each edge can then be fed to the algorithm and interpreted as desired distances in the layout space for each edge (i.e. "spring lengths")--usually after multiplying by some constant to transform to display units (pixels).
If you tell me what language you are using, I may be able to point you to some code examples.

Resources