Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 11-19-2005, 10:59 AM   #1 (permalink)
 
Newb Techie

Join Date: Nov 2005

Posts: 2

KID8311

Default Help me an algorithm

I'm trying to find an edge colouring algorithm.
A k-edge colouring C of a loopless graph ia an assignment of k colours,
1, 2, .... k to the edge of G. The colouring C is proper if no two adjacent edges have the same colour. K must be minimum.
Anyone knew, please help me !!!
KID8311 is offline  
Old 11-19-2005, 12:50 PM   #2 (permalink)
 
Ultra Techie

Join Date: Jul 2005

Posts: 530

TheHeadFL

Send a message via AIM to TheHeadFL
Default

Well... since the graph is loopless I'd imagine you can use some kind of recursive algorithm since you won't visit the same node twice.

Start at some random node and branch out to the rest of the graph. If your start node has N edges, color them 1 - N, and generate N recursive calls that pass along the color (C) of the edge to the node connected to that edge. That node may therefore start again with 1 - N, coloring edges connected to it going outward, excluding the color C of the incoming edge.

This would never work if the graph had loops. It also only works in a fully connected graph. But it should work, off the top of my head, in a loopless connected graph.

Additionally, you would want to assign nodes and edges a unique ID number for the purposes of keeping track of incoming and outgoing edges to each node.

Recursive call might look like....

color_graph(incomingEdge, incomingColor, currentNode).

Where initially you begin with color_graph(NULL, NULL, startNode).

And for each node you would want to do something like

Code:
int rval=0;
for (c = 0; c < numEdges(currentNode) - 1; c++)
{
   nextEdge = getNextEdge(currentNode);
   nextNode = getNextNode(nextEdge);
   if (c != incomingColor) rval=color_graph(nextEdge, c, nextNode);
   else rval=color_graph(nextEdge, numEdges(currentNode), nextNode);
}
if (rval > c) return rval;
else return c;
Now, I don't know if this logic is 100% yet, but it should work. rval would be returning the maximum encountered value of k (color).

In short though, the 'cheating' way to do this is to realize that k can never be smaller than the number of edges going into any one node. Therefore, the node with the most edges determines the minimal value of k.
__________________
Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache)
TheHeadFL is offline  
Old 11-20-2005, 11:03 PM   #3 (permalink)
 
Newb Techie

Join Date: Nov 2005

Posts: 2

KID8311

Default Thank you !

Thanks !!!
I have some problem with this algorithm. In case G is bipartite graph,
is the algrorithm different ? and what is the optimal algorithm for this case.
Could you show me !
KID8311 is offline  
Old 11-21-2005, 05:55 AM   #4 (permalink)
 
Ultra Techie

Join Date: Jul 2005

Posts: 530

TheHeadFL

Send a message via AIM to TheHeadFL
Default

Well then you will have to select a new startNode for each independent connected graph. So if your graph is two separate fully connected subgraphs, you pick a startNode from each of them.

However, since they are not connected and thus not adjacent, you can simply treat them as two totally separate graphs. In fact, you can just run the algorithm on one part, and then on the other, and the max k is just the greater of the two.
__________________
Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache)
TheHeadFL is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On