Structure of Romantic and Sexual relationship

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
77 replies · 15K views
I ran some tests, adding edges randomly and independently of one another. If the expected number of hookups for any given person is around 1, for a few hundred people you do typically get one large component, which is almost a tree (very few cycles)--so perhaps the lack of cycles is not noteworthy.

My source code (python):
Code:
import random
from copy import deepcopy

# create a graph with numnodes nodes, where each edge has a probability
# of existing such that the expected number of edges to a given node
# is avgconnects
# graph is stored as an adjacency list dict
# no self-edges
def randgraph(numnodes,avgconnects):
    graph = {}
    nodes = range(numnodes)
    prob = float(avgconnects)/(numnodes-1)
    for x in nodes:
        graph[x] = set([])
    for x in nodes:
        for y in nodes[:x]:
            if random.random() <= prob:
                graph[x].add(y)
                graph[y].add(x)
    return graph

# create a random graph of boys and girls
# where boy nodes connect only to girl nodes
# and girl nodes connect only to boy nodes
# and the expected number of edges to any node is avgconnects
# (if the number of boys and girls is unequal,
#  this may result in higher or lower averages for each gender)
def boygirlgraph(boynum,girlnum,avgconnects):
    graph = {}
    boys = ['b' + str(x) for x in range(boynum)]
    girls = ['g' + str(x) for x in range(girlnum)]
    prob = float(avgconnects)*(boynum+girlnum)/(2*boynum*girlnum)
    
    for x in boys + girls:
        graph[x] = set([])
    for b in boys:
        for g in girls:
            if random.random() <= prob:
                graph[b].add(g)
                graph[g].add(b)
    return graph

# imperatively remove the node from the graph
# assumes all edges are bidirectional
def removenode(node,graph):
    for x in graph[node]:
        graph[x].remove(node)
    graph.pop(node)

# return a list of connected components, each component being a set of nodes
# the largest components appear first in the list
def componentlist(graph):
    components = []
    tmpgraph = deepcopy(graph)
    while len(tmpgraph) > 0:
        (node,adj) = tmpgraph.iteritems().next()
        curcomp = set([])
        def descend(node):
            adj = tmpgraph[node]
            curcomp.add(node)
            for x in adj:
                if not x in curcomp:
                    descend(x)
        descend(node)
        components.append(curcomp)
        for x in curcomp:
            removenode(x,tmpgraph)
    components.sort(key=len,reverse=True)
    return components

# return the subgraph including only those nodes in the component given
def subgraph(component,graph):
    tmpgraph = {}
    for x in graph:
        if x in component:
            tmpgraph[x] = graph[x] & component
    return tmpgraph

# In a maximal connected component, how many edges would need to be removed
# to turn the component into a tree?
def numcycles(component, graph):
    nedges = 0
    for x in component:
        nedges += len(graph[x])
    nedges /= 2
    # tree has len(component) - 1 edges
    return nedges - len(component) + 1

# convert to graphviz/dot format
def dotfmt(graph):
    conns = [str(a) + ' -- ' + str(b) + ' ;' for a in graph for b in graph[a] if a < b]
    return "graph{\n" + '\n'.join(conns) + '\n}\n'
 
Physics news on Phys.org
The guy connected to 9 pink dots can program in Python.

People who can program in Python are like porn stars.

People who can run Python programs on their computer are like porn star viewers.

A person who can't run Python programs on their computers is like a nerd with a Betamax.
 
Math Is Hard said:
I had boyfriends when I was in high school, but none of them were in high school. I guess there's no mapping for that.

I remember you telling me you liked younger men. Please tell me that happened later on in life.
 
JasonRox said:
I know what school my son is going to now.

Congrats, what are you naming him?

I'm not sure the world can handle a Jason JR.
 
Ah, http://xkcd.com/403/" explains a lot. It was all about esthetics.
 
Last edited by a moderator:
I'm kinda surprised there's a triangle in there. That means a girl had a relationship with both a girl and a boy during 6 months. So is she gay or straight?

Also, why are there no trapezoids?
 
I wonder if http://xkcd.com/540/" was applied?
 
Last edited by a moderator:
HO-LY-****!

I had no idea people were that huge of sluts in high school. Some interesting notes:
-The biggest player had been with 8 girls
-The biggest slut had been with 5 guys

Also, does it not strike anyone else as a bit odd that this whole thing turned out to be planar? What does that imply for the nature of sexual relations?
 
wrongusername said:
... why are there no trapezoids?

KingNothing said:
... does it not strike anyone else as a bit odd that this whole thing turned out to be planar?

Indeed. Where are the concave polygons, dodecahedra, and 4-dimensional hypercubes? Clearly the data has been doctored with.
 
Redbelly98 said:
Indeed. Where are the concave polygons, dodecahedra, and 4-dimensional hypercubes? Clearly the data has been doctored with.

Funny man, but I'm actually serious about the graph being 100% planar. It does seem strange to me, although I can't quite figure out what it means for sex.
 
KingNothing said:
Funny man, but I'm actually serious about the graph being 100% planar. It does seem strange to me, although I can't quite figure out what it means for sex.

Were you hoping for a 3D pornographic picture of students having sex? :-p

A 2D graph is enough to explain this relationship. We understand the 6 month time dimension is not shown here. Is that what you are talking about?
 
I think the question is it's curious that you can draw all those figures and avoid having to cross lines. For example, how would yo do this with a group of five people, all of who have had sex with each other?
 
I see KingNothing's point. There could theoretically be groups of relationships that cannot be represented without crossing lines (or without requiring a third dimension to the graph).

Following OfficeShredders lead, I was about to ask what the simplest group of relationships is. OfficeShredder went for the group of five, but he missed the simpler one: 4 people. i.e. a tetrahedron.

4 people, all of whom have had romantic relationships with each other, cannot be represented in only 2 dimensions without crossing lines.

And that sheds light on the answer to KingNothing's point. This simplest relationship requires some statistically highly unlikely connections. 4 people all having had relationships with each other is unlikely enough, but to do so, it requires a minimum of two same-sex relationships.

Code:
  M
 /|\
F-+-F
 \|/
  M
 
DaveC426913 said:
Following OfficeShredders lead, I was about to ask what the simplest group of relationships is. OfficeShredder went for the group of five, but he missed the simpler one: 4 people. i.e. a tetrahedron.

4 people, all of whom have had romantic relationships with each other, cannot be represented in only 2 dimensions without crossing lines.

And that sheds light on the answer to KingNothing's point. This simplest relationship requires some statistically highly unlikely connections. 4 people all having had relationships with each other is unlikely enough, but to do so, it requires a minimum of two same-sex relationships.

Code:
  M
 /|\
F-+-F
 \|/
  M

No, K_4 is planar:


Code:
  M
 / \\
F---F|
 \ //
  M

Kuratowski's theorem says that a graph is planar iff it avoids K_5 (OfficeShredder's example) and K_3,3. I can't conveniently ASCII art K_3,3 for you, but it's much easier to imagine in this context since doesn't require homosexual relationships.
 
CRGreathouse said:
No, K_4 is planar:


Code:
  M
 / \\
F---F|
 \ //
  M

Kuratowski's theorem says that a graph is planar iff it avoids K_5 (OfficeShredder's example) and K_3,3. I can't conveniently ASCII art K_3,3 for you, but it's much easier to imagine in this context since doesn't require homosexual relationships.

Oh, right. I had a hidden assumption of using only straight lines.

I don't know Kuratowskian math, but reading up on it, I can see that there are some groups that cannot be made, even allowing for circuitous paths. This seems highly reminescent of the 5 house puzzle. (Shoot, I can't remember what it's called. It the one where you have to join 5 people to 5 houses without any paths crossing.)
 
Minor (ha, ha) correction: planar graphs can't contain K_5 or K_3,3 or any subdivision of either. (Obvious only in my own head.)

DaveC426913 said:
I can see that there are some groups that cannot be made, even allowing for circuitous paths.

Well you can make them, just not on a plane without crossing.K_3,3 could be three males and three females, where each person is adjacent to/has had a romantic relationship with everyone of the opposite sex.