wu :: forums
« wu :: forums - Mutigraph to Undirected Graph »

Welcome, Guest. Please Login or Register.
Nov 25th, 2024, 9:25am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: SMQ, Icarus, william wu, Grimbal, Eigenray, towr, ThudnBlunder)
   Mutigraph to Undirected Graph
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Mutigraph to Undirected Graph  (Read 1113 times)
johny_cage
Full Member
***





   


Gender: male
Posts: 155
Mutigraph to Undirected Graph  
« on: Nov 18th, 2007, 3:25am »
Quote Quote Modify Modify

You have given an adjacency list representation of a multigraph G = (V,E), describe an O(V+E) time algorithm to compute the adjacency-list representation of the "equivalent" undirected graph G' = (V,E'), where E' consists of the edges in E with all multiple edges between two vertices replaced by a single edge and with all self-loops removed.
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Mutigraph to Undirected Graph  
« Reply #1 on: Nov 18th, 2007, 7:02am »
Quote Quote Modify Modify

Initialize the adjacency matrix to empty; then fill in all the edges, except those on the diagonal.
Although, I suppose that presupposes direct mapping vertex to matrix column/row. I suppose a hashtable might be an option if the vertices aren't already numbered sequentially and we cant' attach a number to them.
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
johny_cage
Full Member
***





   


Gender: male
Posts: 155
Re: Mutigraph to Undirected Graph  
« Reply #2 on: Nov 18th, 2007, 8:25am »
Quote Quote Modify Modify

but we have to find adjacency list, and if we use adjacency matrix then our algorithm will take O(|V|2) space complexity, and also to initialize it to 0, will take same time.
So plzz help me if I m going to the wrong direction..
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Mutigraph to Undirected Graph  
« Reply #3 on: Nov 18th, 2007, 9:14am »
Quote Quote Modify Modify

Hmm, adjacency list is just a list of pairs (v, v')? (I'm not well-versed in graph theory and terminology)
I suppose you could go with a hash-table to attain uniqueness (and weeding out self-loops is trivial enough).
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
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