#18250: G.triangles_count speedup
-------------------------+-------------------------------------------------
Reporter: | Owner:
ncohen | Status: needs_review
Type: | Milestone: sage-6.7
enhancement | Resolution:
Priority: major | Merged in:
Component: graph | Reviewers:
theory | Work issues:
Keywords: | Commit:
Authors: | e780f711afba40b34c0d11b65adaf3cc4429fac2
Nathann Cohen | Stopgaps:
Report Upstream: N/A |
Branch: |
public/18250 |
Dependencies: |
-------------------------+-------------------------------------------------
Changes (by ncohen):
* status: new => needs_review
* commit: => e780f711afba40b34c0d11b65adaf3cc4429fac2
* branch: => public/18250
Old description:
> I thought that we had a decent implementation of `G.triangles_count`.
> Turns out that we did not.
>
> Here is what the branch does:
>
> - Exception on non-simple graphs. The digraph version can handle loops
> (it
> cannot handle multiple edges) and the graph version cannot handle any
> of the
> two.
>
> - (obvious) speedup in the 'iter' algorithm. Before:
> {{{
> sage: %timeit _=g.triangles_count(algorithm='iter')
> 1 loops, best of 3: 10.2 s per loop
> }}}
> After:
> {{{
> sage: g=graphs.RandomGNP(700,.3)
> sage: %timeit _=g.triangles_count(algorithm='iter')
> 1 loops, best of 3: 6.37 s per loop
> }}}
>
> - Added `triangles_count` in `static_sparse_graph` and another one in
> `static_dense_graph`. They first copy the graph in a proper data
> structure and
> count the triangles on the copy. They can take require more memory
> (though
> they are 100000x cheaper than the default data structure)
>
> - The default algorithm is 'iter' in the code but 'matrix' in the doc.
> Fixed:
> `sparse_copy` is now the default.
>
> Overall, comparing default implementations:
>
> Before
> {{{
>
> }}}
>
> After
> {{{
>
> }}}
New description:
I thought that we had a decent implementation of `G.triangles_count`.
Turns out that we did not.
Here is what the branch does:
- Exception on non-simple graphs. The digraph version can handle loops (it
cannot handle multiple edges) and the graph version cannot handle any of
the
two.
- (obvious) speedup in the 'iter' algorithm. Before:
{{{
sage: %timeit _=g.triangles_count(algorithm='iter')
1 loops, best of 3: 10.2 s per loop
}}}
After:
{{{
sage: g=graphs.RandomGNP(700,.3)
sage: %timeit _=g.triangles_count(algorithm='iter')
1 loops, best of 3: 6.37 s per loop
}}}
- Added `triangles_count` in `static_sparse_graph` and another one in
`static_dense_graph`. They first copy the graph in a proper data
structure and
count the triangles on the copy. They can take require more memory
(though
they are 100000x cheaper than the default data structure)
- The default algorithm is 'iter' in the code but 'matrix' in the doc.
Fixed:
`sparse_copy` is now the default.
Overall, comparing default implementations:
Before
{{{
sage: g = graphs.RandomGNP(500,.5)
sage: %timeit g.triangles_count()
1 loops, best of 3: 9.78 s per loop
}}}
After
{{{
sage: g = graphs.RandomGNP(500,.5)
sage: %timeit g.triangles_count()
10 loops, best of 3: 162 ms per loop
}}}
--
Comment:
New commits:
||[http://git.sagemath.org/sage.git/commit/?id=e780f711afba40b34c0d11b65adaf3cc4429fac2
e780f71]||{{{trac #18250: G.triangles_count speedup}}}||
--
Ticket URL: <http://trac.sagemath.org/ticket/18250#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.