Opened 13 years ago

Closed 13 years ago

# Average distance, Wiener Index, Szeged index

Reported by: Owned by: ncohen rlm major sage-4.3 graph theory sage-4.3.rc1 Nathann Cohen Robert Miller N/A

### Description

Hello !!

This patch defines :

• The average distance between vertices : Graph.average_distance
• The Szeged Index of a graph : Graph.szeged_index
• The Wiener Index of a graph : Graph.wiener_index

Everything this patch adds (except the average distance) is documented in : http://www.sciencedirect.com/science?_ob=ArticleURL&_udi=B6TY9-3VVCHY8-9&_user=10&_rdoc=1&_fmt=&_orig=search&_sort=d&_docanchor=&view=c&_acct=C000050221&_version=1&_urlVersion=0&_userid=10&md5=6d22be39b064af51023439c3bb59c459

This reference is mentioned in the docstrings.

Nathann

### comment:1 Changed 13 years ago by ncohen

Status: new → needs_review

### comment:2 Changed 13 years ago by mhansen

In the docstrings, you should not put comments on the sage: line like in

EXAMPLE::

sage: # From [2], cited in [1]
sage: g=graphs.PathGraph(10)
sage: w=lambda x: (x*(x*x -1)/6)
sage: g.wiener_index()==w(10)
True

EXAMPLE:

From [2], cited in [1]::

sage: g=graphs.PathGraph(10)
sage: w=lambda x: (x*(x*x -1)/6)
sage: g.wiener_index()==w(10)
True

Also, you should see the way that references are handled elsewhere in the Sage library.

### comment:3 Changed 13 years ago by ncohen

I hope you will prefer this one ! I had taken as examples other docstrings which you may find badly formatted... This time, I took as an example Minh's code from Cliques functiosn, knowing that never I witnessed Minh making the slightest error :-)

Nathann