wu :: forums
« wu :: forums - Socialist graphs »

Welcome, Guest. Please Login or Register.
May 4th, 2024, 8:59pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: SMQ, ThudnBlunder, william wu, Grimbal, towr, Icarus, Eigenray)
   Socialist graphs
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Socialist graphs  (Read 1819 times)
Aryabhatta
Uberpuzzler
*****






   


Gender: male
Posts: 1321
Socialist graphs  
« on: Sep 20th, 2004, 10:38pm »
Quote Quote Modify Modify

Let G be a simple undirected connected graph with the value 0 assigned to each vertex except a dictator vertex D, which has the value 1. The pair (G,D) is called socialist if each vertex of G can be made to have an even a value divisible by 3 by repeated application of the following process: Pick any edge of G and increment the values of the endpoints of that edge by 1.
 
Given a graph G and a dictator D, give an algorithm to decide if (G,D) is socialist.
 
 
[EDIT] Modified the post to replace even by multiple of 3 [/EDIT]
« Last Edit: Sep 21st, 2004, 10:02am by Aryabhatta » IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Socialist graphs  
« Reply #1 on: Sep 20th, 2004, 11:38pm »
Quote Quote Modify Modify

::Isn't it always impossible?
The sum over the values of all vertices begins odd (1+k*0=1), and at each step you increase it by 2, so it will never be even as it would be when all vertices are even.
::
« Last Edit: Sep 20th, 2004, 11:39pm by towr » IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
baudolino
Guest

Email

Re: Socialist graphs  
« Reply #2 on: Sep 21st, 2004, 7:19am »
Quote Quote Modify Modify Remove Remove

How about comunist graphs?
 
Let G be a simple undirected connected graph with the value 0 assigned to each vertex except a dictator vertex D, which has the value 1. The pair (G,D) is called comunist if each vertex of G can be made to have an even value by repeated application of the following process: Pick any VERTEX of G, say v, and increment the values of the vertices adjacent to vertex v by 1. (The value at v is not changed.)
 
Given a graph G and a dictator D, give an algorithm to decide if (G,D) is comunist.  
IP Logged
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Re: Socialist graphs  
« Reply #3 on: Sep 21st, 2004, 8:43am »
Quote Quote Modify Modify

I looks like solving a linear equation in ([bbz]/2)n.
IP Logged
Aryabhatta
Uberpuzzler
*****






   


Gender: male
Posts: 1321
Re: Socialist graphs  
« Reply #4 on: Sep 21st, 2004, 10:04am »
Quote Quote Modify Modify

You are right towr. I modified the post so that each value should now be a multiple of 3.  
 
Sorry about that, i was trying to reduce the amount of typing and ended up botching the problem itself.  Embarassed
IP Logged
baudolino
Guest

Email

Re: Socialist graphs  
« Reply #5 on: Sep 21st, 2004, 12:59pm »
Quote Quote Modify Modify Remove Remove

An algorithm, probably not optimal, for the modified version (where the value of each vertex is a multiple of 3) is as follows.
 Since only the values mod 3 matters, we consider the values be to in Z/3Z. Given (G,D), the idea is to construct a NFA over an alphabet {z} (consisting of 1 element) that models this problem. The states are all possible assignments of values from Z/3Z to each of the vertices of G. The non-deterministic delta function associates to any state [and the symbol z,]  all the possible states obtained by applying the rule in the problem. That is, given an edge, it increases mod 3 the values in the endpoints of the edge, and leaves all other values unchanged. The initial state in NFA is the state corresponding to the initial case, in which vertex D has value 1 and all other vertices have value 0. The final state is the one with 0s in all states. The problem is now to determine where the language accepted by this NFA is nonempty.
Determining whether the language accepted by NFA is nonempty is straightforward when you consider the associated boolean matrix M. This matrix M has order n x n , where n is the number of states in the NFA. The entry (i,j) in M is 1 when there is a symbol (a string of length 1) in the alphabet that takes the state i into state j, and 0 if there is no such symbol. Consider all the powers of matrix M. (Remember to use boolean operations (1+1=1) when computing the powers of M.) Starting from a certain power, this sequence of powers will be periodic, so there are a finite number of possible powers of M.  Consider two 1 x n vectors v_S and v_F: v_S corresponds to the initial state (the j-th entry in v_S is 1 if j is the starting state, and is 0 otherwise), and v_F corresponds to the final states (the j-th entry in v_F is 1 if j is a final state, and is 0 otherwise). The language accepted by the NFA is nonempty if and only if there is a power of M, say M^k, such that v_S * M^k *(v_F)^transpose = 1. Since there is a finite number of powers of M, all is finite.
 
IP Logged
baudolino
Guest

Email

Re: Socialist graphs  
« Reply #6 on: Sep 21st, 2004, 1:06pm »
Quote Quote Modify Modify Remove Remove

Correction in the definition of M. The entry (i,j) in M is 1 when there is a string of length 0 or 1 in the alphabet that takes the state i into state j, and 0 if there is no such string.
IP Logged
Aryabhatta
Uberpuzzler
*****






   


Gender: male
Posts: 1321
Re: Socialist graphs  
« Reply #7 on: Sep 21st, 2004, 2:57pm »
Quote Quote Modify Modify

on Sep 21st, 2004, 12:59pm, baudolino wrote:

<snip>
 The states are all possible assignments of values from Z/3Z to each of the vertices of G.  
<snip>
Since there is a finite number of powers of M, all is finite.
 

 
Yes, finite but exponential (in number of vertices) or worse. If n is the number of vertices and m is the number of edges I think we can give an O(n+m) algorithm (assuming neighbouring vertices and edges of any given vertex can be found in constant time).
 
IP Logged
baudolino
Guest

Email

Re: Socialist graphs  
« Reply #8 on: Sep 21st, 2004, 3:25pm »
Quote Quote Modify Modify Remove Remove

or like Gimbal said, solve a system of linear equations in Z/3Z.  
 
Let V be the number of vertices of graph G and E be the number of edges of G. Label the vertices from 1 through V and the edges from 1 through E. Define an array I of length V by I[j]=1 if j=D, and I[j]=0 otherwise. If 1<=e<=E, define an array A_e of length V by A_e[j]=1 if vertex j is one of the 2 endpoints of edge e and A_e[j]=0 otherwise. The problem is equivalent to finding an algorithm for solving in Z/3Z the equation I + \sum_{e=1}^{E} n_e * A_e =0, where n_e are in Z/3Z.  This is a system of V equations in E unknowns with coeffcients in Z/3Z.
 
 Assume that each operation (addition, muliplication) in Z/3Z is counted as a unit operation. Using Gaussian elimination, the complexity of solving the system is O(V^2 * E). Since  E is in O(V^2), the complexity is O(V^4).
IP Logged
Aryabhatta
Uberpuzzler
*****






   


Gender: male
Posts: 1321
Re: Socialist graphs  
« Reply #9 on: Sep 21st, 2004, 3:57pm »
Quote Quote Modify Modify

on Sep 21st, 2004, 3:25pm, baudolino wrote:

 
like Gimbal said, solve a system of linear equations in Z/3Z.  

 
 
Yes that works and is a pretty elegant solution I think. In fact, it works for the communist graph problem and a host of other such similar problems (Example: google for the lights out puzzle, or look at the locks and switches puzzle in the cs forum here).  But for the specific case of the socialist graph problem, we can do better  (like in the case of the locks and switches problem). Maybe we can do the same with the communist graph problem too...  
 
« Last Edit: Sep 21st, 2004, 3:58pm by Aryabhatta » IP Logged
Aryabhatta
Uberpuzzler
*****






   


Gender: male
Posts: 1321
Re: Socialist graphs  
« Reply #10 on: Sep 22nd, 2004, 3:36pm »
Quote Quote Modify Modify

I guess it is too early for a hint. Feel free to ignore this  Smiley
:

 
The choice of the dictator vertex does not matter.
Trees and n-D cubes are examples of un-socialist graphs...
 

:
IP Logged
Aryabhatta
Uberpuzzler
*****






   


Gender: male
Posts: 1321
Re: Socialist graphs  
« Reply #11 on: Sep 24th, 2004, 8:29am »
Quote Quote Modify Modify

More examples of un-socialist graphs
:
 
Chessboards of any size (i.e nxn grids), the graph appearing in the utilities puzzle (K33). Cycles with even number of edges.
 
:
IP Logged
baudolino
Guest

Email

Re: Socialist graphs  
« Reply #12 on: Sep 24th, 2004, 12:35pm »
Quote Quote Modify Modify Remove Remove

examples of socialist graphs:
 
Any graph that contains an odd-length cycle connected to D
IP Logged
Aryabhatta
Uberpuzzler
*****






   


Gender: male
Posts: 1321
Re: Socialist graphs  
« Reply #13 on: Sep 24th, 2004, 2:02pm »
Quote Quote Modify Modify

Right baudolino! Since G is a connected graph, you don't have to explictly mention connectivity to D.
 
Once we can prove that those are the only socialist graphs, we should have an algorithm.
IP Logged
baudolino
Guest

Email

Re: Socialist graphs  
« Reply #14 on: Sep 24th, 2004, 7:51pm »
Quote Quote Modify Modify Remove Remove

G connected. G socialist iff G has an odd cycle.
 
Ore direction: (try drawing a figure) If G has an odd cycle, it has a subgraph consisting of an odd cycle and a tail connecting one node in the cycle with vertex D. Numbers will be assigned to the edges of the subgraph as follows. Start along the tail from D until the tail connects with the odd cycle, and consider the edges along the way. Starting with a 2, assign 2s and 1s alternatively to these edges. Consider the last edge in this tail and say the number assigned to it is y. Assign 1s and 2s alternatively to the edges of the odd cycle, so that the y is assigned to the two edges of the cycle where the cycle connected with the tail. Now, for any edge apply the rule t times, where t is the number assigned to the edge. In the resulting subgraph, the number in the vertices are all 0.  
The remaining direction: Consider a graph with no odd cycles.  The vertices of such a graph have coloring with 2 colors, so that any 2 adjacent vertices have different colors. Think of such  a coloring as an assignment of +'s and -'s to the vertices. Say the vertex v is assigned sign sign(v). Consider the invariant I = Sum sign(v)*n(v), where the sum runs over all vertices, n(v) is the number assigned at the vertex v, and the sum is computed in Z/3Z. I is invariant under the rule. Clearly, I has different values for the initial assignment (1 for vertex D and 0 for all other vertices) and for the final assignment (0 for all vertices), so the initial assignment can not be transformed by a successive application of the rule into the final assignment. Therefore G is not-socialist.
 
Deciding whether G has an odd cycle (or equivalently a coloring with 2 colors) can be done in O(V+E)
 
A similar proof works in general (for any initial assignment and Z/3Z replaced by Z/dZ, where d > 1 is a positive odd integer) to prove the following.
 
G connected graph. Let S be an assignment of numbers from Z/dZ to the vertices of G. Consider the rule, which applied to an edge, increments (in Z/dZ) the values at the two ends of the edge.  
(a) If G has an odd cycle, then any two assignments are equivalent under the rule (i.e. one can be obtained from the other by successively applying the rule).
(b) If G has no odd cycles, consider an assignment of +'s and -'s to the vertices so that no two adjacent vertices are assigned the same symbol. If S is an assignment of numbers from Z/dZ to the vertices of G , let I(S) = Sum sign(v) * n(v), as above. Two assignments S and S' are equivalent iff I(S) = I(S').
 
When d is even, there is a problem when the numbers are assigned to the 3 edges adjacent to the vertex where the odd cycle connects with the tail. The two edges on the cycle need to be assigned the same number x. If y is the number assigned to the 3rd edge (on the tail), given y, the equation 2x+y=0 in Z/dZ sometimes does not have any solution x.
IP Logged
Aryabhatta
Uberpuzzler
*****






   


Gender: male
Posts: 1321
Re: Socialist graphs  
« Reply #15 on: Sep 25th, 2004, 1:29pm »
Quote Quote Modify Modify

Right baudolino!
 
A connected graph G is not socialist if and only if G is bipartite (or 2 colourable). Depending on the representation of G, we have efficient algortihms to determine if G is 2-colourable.
 
Maybe this will give us some interesting properties of the 'related' matrices over [bbf]3.
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board