A question about graph algorithm

  • Context: Undergrad 
  • Thread starter Thread starter gimmytang
  • Start date Start date
  • Tags Tags
    Algorithm Graph
Click For Summary

Discussion Overview

The discussion revolves around generating a random graph with specific constraints: a maximum of two edges per node and no loops. Participants explore potential algorithms and clarify the implications of the conditions set for the graph.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant suggests starting with a partition of the nodes and forming edges based on the order of nodes in each group, implying that the structure would resemble a line or strip.
  • Another participant questions the feasibility of the conditions, asking for clarification on the definition of a loop and whether it refers to a cyclic structure or one that encompasses all nodes.
  • Some participants emphasize that the maximum edge degree of 2 allows for configurations without loops, noting that end nodes can have only one edge.
  • A later reply corrects an earlier misunderstanding about the conditions, indicating that the problem should be simpler than initially thought.

Areas of Agreement / Disagreement

Participants express differing views on the implications of the conditions, particularly regarding the possibility of loops. There is no consensus on the interpretation of "loop" or the feasibility of generating such a graph under the given constraints.

Contextual Notes

Participants have not fully resolved the definitions of loops and the implications of the maximum edge degree, which may affect the proposed approaches to generating the graph.

gimmytang
Messages
20
Reaction score
0
Suppose there are 10 nodes in a graph, I need to generate edges between nodes, but there are two conditions to be satisfied:
1) each node can have maximize of two edges.
2) no loop in the graph.
The question is how to run a program which gives an algorithm to generate such a graph randomly?

gim :!)
 
Mathematics news on Phys.org
Edited: Not really sure if that's what he was after so I deleted it.
 
Last edited:
Oh this is easy... first you choose a partition of 10... ie a set of positive integers that add to ten.

Then for each number n in the partition pick n nodes. So you broken up your ten nodes into m groups where m is the amount of numbers in your partition.

Then for each group choose an order

Then your edges are just the edges so that each group is a line in the order. ie if one group has edges 6,3,8,2 in that order then your edges are (6,3), (3,8), (8,2)


This is just because if every node's edge degree is at most 2 and there are no loops then every connected set is just a line or a strip (or whatever the proper terminology is)
 
Thank you, snoble!
 
is that even possilbe?
or do you mean like a eulerian or hamiltonian...what is your definition of a loop-one that encompasses all the nodes or one that's cyclic in <n nodes?

because with those 2 conditions you'll always get a loop...
 
I think the key is that each node has a maximum edge degree of 2. emphasis on maximum.
 
neurocomp2003 said:
because with those 2 conditions you'll always get a loop...

That's not true. End nodes would just have 1 edge. He said a maximum of 2, not exactly 2.
 
wups my bad...thoght it said exactly two =]
the question shouhld be easy then
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
5K
Replies
86
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K