Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: number of Trangles in a graph-network

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99373] Re: number of Trangles in a graph-network
  • From: Peter Pein <petsie at dordos.net>
  • Date: Mon, 4 May 2009 06:00:18 -0400 (EDT)
  • References: <gtefaf$197$1@smc.vnet.net>

Luca Cinacchio schrieb:
> Greetings,
> 
> having a graph (network, i.e. one created with RandomGraph) wich can have  
> not connected nodes, I would like to count the total number of triangles  
> inside the graph.
> I gave a look to Combinatorica and its related book by Pemmaraju Skiena,  
> but I did'nt find any solution (maybe I am wrong). Do you know if there is  
> a easy way to answer this problem with Mathematica and/or Combinatorica?
> Thanks in advance.
> 

The following does not check for triples of points being colinear, but it 
seems to be a possible starting point:

In[1]:= <<Combinatorica`
In[2]:= List@@(rg=RandomGraph[7,2/3])
Out[2]= 
{{{{1,2}},{{1,3}},{{2,3}},{{1,4}},{{2,4}},{{3,4}},{{2,5}},{{4,5}},{{1,6}},{{2,6}},{{3,6}},{{1,7}},{{3,7}},{{4,7}},{{6,7}}},
{{{0.62349,0.781831}},{{-0.222521,0.974928}},{{-0.900969,0.433884}},{{-0.900969,-0.433884}},{{-0.222521,-0.974928}},{{0.62349,-0.781831}},{{1.,0}}}}
In[3]:= GraphPlot@rg
..graphics..
In[4]:= 
Total[ReplaceList[rg[[1]],{___,{{a_,b_}},___,{{a_,c_}},___,{{b_,c_}},___}:>1]]
Out[4]= 13

Peter


  • Prev by Date: Re: Solving the system with inexact coefficients
  • Next by Date: Re: DumpSave of InterpolatingFunction increases its execution times
  • Previous by thread: number of Trangles in a graph-network
  • Next by thread: Re: number of Trangles in a graph-network