Macaulay2 » Documentation
Packages » Graphs :: density
next | previous | forward | backward | up | index | toc

# density -- computes the density of a graph

- Usage:
    `d = density G`
- Inputs:
  - G, a graph,
- Outputs:
  - d, a rational number, the density of G

## Description

A dense graph has a high edge to vertex ratio, whereas a sparse graph has a low edge to vertex ratio. Density is equal to 2*|E| divided by |V|*(|V|-1). A complete graph has density 1; the minimal density of any graph is 0.

    i1 : G = graph({{1,2},{2,3},{3,4},{4,2},{1,4}},EntryMode=>"edges");

    i2 : density G

         5
    o2 = -
         6

    o2 : QQ

## See also

- degreeCentrality -- Returns the degreeCentrality of a vertex of a graph

## Ways to use density:

- `density(Graph)`

## For the programmer

The object density is a method function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Graphs.m2:3399:0.