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.
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.
Could someone explain in pretty simple words why the normalization of many network analysis indicies (graph theory) is n(n - 1), where n – the graph size? Why do we need to take into account (n - 1)?
Most network measures that focus on counting edges (e.g. clustering coefficient) are normalized by the total number of possible edges. Since every edge connects a pair of vertices, we need to know how many possible pairs of vertices we can make. There are n possible vertices we could choose as the source of our edge, and therefore there are n-1 possible vertices that could be the target of our edge (assuming no self-loops, and if undirected divide by 2 bc source and target are exchangeable). Hence, you frequently encounter $n(n-1)$ or $\binomal{n}{2}$.
My graph is as follows:
I need to find a maximum weight subgraph.
The problem is as follows:
There are n Vectex clusters, and in every Vextex cluster, there are some vertexes. For two vertexes in different Vertex cluster, there is a weighted edge, and in the same Vextex cluster, there is no edge among vertexes. Now I
want to find a maximum weight subgraph by finding only one vertex in each
Vertex cluster. And the total weight is computed by adding all weights of the edges between the selected vertex. I add a picture to explain the problem. Now I know how to model this problem by ILP method. However, I do not know how to solve it by an approximation algorithm and how to get its approximation ratio.
Could you give some solutions and suggestions?
Thank you very much. If any unclear points in this description,
please feel free to ask.
I do not think you can find an alpha-approx for this problem, for any alpha. That is because if such an approximation exists, then it would also prove that the unique games conjecture(UGC) is false. And disproving (or proving) the UGC is a rather big feat :-)
(and I'm actually among the UGC believers, so I'd say it's impossible :p)
The reduction is quite straightforward, since any UGC instance can be described as your problem, with weights of 0 or 1 on edges.
What I can see as polynomial approximation is a 1/k-approx (k the number of clusters), using a maximum weight perfect matching (PM) algorithm (we suppose the number of clusters is even, if it's odd just add a 'useless' one with 1 vertex, 0 weights everywhere).
First, you need to build a new graph. One vertex per cluster. The weight of the edge u, v has the weight max w(e) for e edge from cluster u to cluster v. Run a max weight PM on this graph.
You then can select one vertex per cluster, the one that corresponds to the edge selected in the PM.
The total weight of the solution extracted from the PM is at least as big as the weight of the PM (since it contains the edges of the PM + other edges).
And then you can conclude that this is a 1/k approx, because if there exists a solution to the problem that is more than k times bigger than the PM weight, then the PM was not maximal.
The explanation is quite short (lapidaire I'd say), tell me if there is one part you don't catch/disagree with.
Edit: Equivalence with UGC: unique label cover explained.
Think of a UGC instance. Then, every node in the UGC instance will be represented by a cluster, with as many nodes in the cluster as there are colors in the UGC instance. Then, create edge with weight 0 if they do not correspond to an edge in the UGC, or if it correspond to a 'bad color match'. If they correspond to a good color match, then give it the weight 1.
Then, if you find the optimal solution to an instance of your problem, it means it corresponds to an optimal solution to the corresponding UGC instance.
So, if UGC holds, it means it is NP-hard to approximate your problem.
Introduce a new graph G'=(V',E') as follows and then solve (or approximate) the maximum stable set problem on G'.
Corresponding to each edge a-b in E(G), introduce a vertex v_ab in V'(G') where its weight is equal to the weight of the edge a-b.
Connect all of vertices of V'(G') to each other except for the following ones.
The vertex v_ab is not connected to the vertex v_ac, where vertices b and c are in different clusters in G. In this manner, we can select both of these vertices in an stable set of G' (Hence, we can select both of the corresponding edges in G)
The vertex v_ab is not connected to the vertex v_cd, where vertices a, b, c and d are in different clusters in G. In this manner, we can select both of these vertices in an stable set of G' (Hence, we can select both of the corresponding edges in G)
Finally, I think you can find an alpha-approximation for this problem. In other words, in my opinion the Unique Games Conjecture is wrong due to the 1.999999-approximation algorithm which I proposed for the vertex cover problem.
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.
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