I have a csv file with graph formatted as edge list, ie Source, Target, Label, Type (Directed), Weight (all weights = 1)
It consist of 31900 edges as i checked in Data laboratory.
Then i go to view my graph and in the Context (right top corner of Gephi) i see:
Nodes: 1869
Edges: 3160
Why number of edges is not 31900, why it's 10 times smaller??
My guess Gephi somehow reduce this number, because if i compute Average weighted degree it shows 17, so if i multiply 1869 * 17,01 = 31959 - exactly the number of edges.
So where that edges on graph?
Edge is a connection of nodes, so edges are equal(same) when its source and target is same. Though your data consist of 31900 edges, maybe there're many identical edge, I guess.
To validate this hypothesis, you can calculate the weight and you would see the edge now won't be 1 anymore. And the sum of the edge's weight are still 31900.
Related
Suppose I have a graph with node weights, for example:
If a node has weight -1, it is "happy". If a node has positive weight, it is "unhappy", and wants to leave the graph.
How do I efficiently calculate which nodes I should kick out of the graph in order to minimize unhappiness (i.e., total graph weight), while making sure that the graph remains connected?
For instance, in this case, I can't get rid of the 10, 8, and 10 nodes, since that would disconnect the graph. The optimal solution in this case seems to be 10 + 8 + 5 = 23.
Small correction : the optimal solution in your example is 2 + 10 + 8 + 5 = 25. Nothing prevents you from removing all but connecting "unhappy" nodes.
On the discussion about bridge : bridge are edges, here you remove nodes. This makes a big difference : when removing edges, the nodes remains, and thus you cannot remove too many of them. When removing nodes, their attached edges are removed too, and you can be much more aggressive. So much that you only need to keep path between clusters of "happy" nodes. Everything else is removed.
How do you do that ?
Replace each cluster of happy nodes (happy nodes that are connected) by one happy node. (keep track of the replaced nodes)
For each edge between an happy and an unhappy node in the starting graph, make an edge between the node representing the cluster of the happy node, and the same unhappy node. The weight is the same as the original weight.
For each pair of happy nodes (representing the original clusters), find the shortest path between them. If this path pass through a third happy node, ignore it. Else, make an edge between the two happy nodes, with a weight equal to the total weight of the shortest path. (keep track of the nodes making the path)
Remove every unhappy node
Find the MST (minimum spanning tree) of the graph. Only keep the selected edges.
Replace each remaining edge of your graph by the path it represents
Replace each happy node by the cluster of happy nodes it represents
I tried to keep this solution in a high language, I can edit it to be more rigorous if needed.
Given an undirected graph with weighted edges you are asked to find the minimum single edge weight to connect all nodes.
enter image description here
Given this graph the answer would be 3, as you can travel through all edges without using an edge with more than 3 weight.
What is an efficient way to solve this?
I have got a graph network and the edges of the graph are weighted. Is there a way to distribute the edge weights to nodes?
I'd like to know if there is a way to derive node weight or edge weight from each other.
I noticed a similar post here, which is the inverse of my problem. I am not sure if there is a similar approach that can be used for my problem.
EDIT:
For instance, for a graph like this (created from the commands given here) and each edge has a weight associated with it.
Example: Nodes i and j are linked by edge $e_{ij}$ that has weight $w_{ij}$
If the node weights are denoted by $nw_i$ (i = 1 to Number of nodes), the weight of any two nodes should sum up to the weight of the edge that links those nodes. i.e. $nw_i$ + $nw_j$ should be equal to $w_{ij}$,
$nw_j$ + $nw_k$ should be equal to $w_{jk}$ and so on.
Consider a graph that has weights on each of its nodes instead of between two nodes. Therefore the cost of traveling to a node would be the weight of that node.
1- How can we represent this graph?
2- Is there a minimum spanning path algorithm for this type of graph (or could we modify an existing algorithm)?
For example, consider a matrix. What path, when traveling from a certain number to another, would produce a minimum sum? (Keep in mind the graph must be directed)
if one don't want to adjust existing algorithms and use edge oriented approaches, one could transform node weights to edge weights. For every incoming edge of node v, one would save the weight of v to the edge. Thats the representation.
well, with the approach of 1. this is now easy to do with well known algorithms like MST.
You could also represent the graph as wished and hold the weight at the node. The algorithm simply didn't use Weight w = edge.weight(); it would use Weight w = edge.target().weight()
simply done. no big adjustments are necessary.
if you have to use adjacency matrix, you need a second array with node weights and in adjacency matrix are just 0 - for no edge or 1 - for an edge.
hope that helped
I want to generate a sequence of the number of vertices in all graphs which each edge has the same number of leaving edges. I dont have to generate the whole sequence. Let's say the first 50 if exists.
I want:
Input: the number of edges leaving each vertex
Output: a sequence of the number of vertices
So far, I have looked at complete graphs. Complete graphs with n vertices always have n-1 edges leaving each vertex. But there are other kinds of graphs that have this property. For example, some polyhedrons, such as snub dodecahedron and truncated icosidodecahedron have this property.
How should I approach my problem?
I think you mean regular graphs:
http://en.wikipedia.org/wiki/Regular_graph
http://mathworld.wolfram.com/RegularGraph.html
I made a regular graph generator which isn't flawless by the way:
once you generate the nodes, say from 1 to n. You want regularity r.
For node 1, make connections to the following nodes until you reach degree r for node 1.
For node 2 you already have degree 1 (because of node 1), you connect again to further nodes until you reach degree r for node 2 too. And this way till the last node.
The flaw is that you can't define an r-regular graph for any number of nodes. The algorithm mentioned doesn't detect that, so some errors may occur. Also, this isn't a random r-regular graph generator, but instead give one possible solution.
I'm not much of an explainer, so please ask if the description lacks somewhere.