Skip to the content.

Student Name: Vipul Gupta

Organization: SageMath

Project Mentor: Dr. David Coudert

Project Title: Efficient methods for Diameter, Radius and All Eccentricities computations

Project URL: https://summerofcode.withgoogle.com/projects/#4665936407166976


Organization Overview

SageMath is a free open-source mathematics software system licensed under the GPL. It builds on top of many existing open-source packages: NumPy, SciPy, matplotlib, Sympy, Maxima, GAP, FLINT, R and many more. Access their combined power through a common, Python-based language or directly via interfaces or wrappers. Along with that SageMath has its own implementation of various algorithms and methods, thereby increasing the overall functionality. SageMath has been actively participating in GSoC program since 2012.


Project Overview

This project consists of two parts :

  sage: G = graphs.RandomGNP(1000, 0.6)
  sage: %time G.radius(algorithm = 'BFS')  // previous scenario
  CPU times: user 2min 9s, sys: 26 s, total: 2min 35s
  Wall time: 2min 35s
  2
  sage: %time G.radius(algorithm = 'DHV')  // current scenario
  CPU times: user 181 ms, sys: 7.99 ms, total: 189 ms
  Wall time: 188 ms
  2

Getting Started

I was already familiar with Github. But SageMath’s development takes place on Trac server. So, I followed SageMath’s developer guide to setup and get myself familiar with trac server. To have a hands-on experience in SageMath’s development, I started by contributing to the open tickets which were pending for a long-time. Few of them are mentioned below -


Community Bonding Period

This period involved discussing layout for the project and deciding locations for each method inside the Graph module. Also, organizing radius, diameter, and eccentricity computation method separately for undirected and directed graphs in graph.py and digraph.py respectively.

Related Ticket - #29660


Phase - I

1). Implemented Radius computation methods for (weighted) undirected graphs proposed in [1].

Related ticket : #29715

Pseudo-Code


2). Implemented Diameter computation for (weighted) undirected graphs proposed in [1].

Related ticket : #29744

Pseudo-Code


3). Implemented All eccentricities computation methods for (weighted) undirected graphs proposed in [1].

Related ticket : #27934

Pseudo-Code


4). Fixed a small bug in shortest_path_length method in generic_graph.py.

Related ticket: #29734


Phase - II

1). Implemented weighted version of 2Dsweep method for computation of lower bound on the diameter of weighted directed graphs given in [2] and implemented DiFUB (Directed iterative Finge Upper Bound) method for exact computation of diameter of (weighted) directed graphs proposed in [3].

Related ticket : #29422, #30039

Pseudo-Code for DiFUB


2). Improved overall consistency and documentation in usage of weight_function in graph module.

Related ticket : #30081


Phase - III

1). Completed memory efficient implementation of wiener index for (weighted) (di)graphs by avoiding to compute and store into memory the full distance matrix. This way we can compute this index for larger graphs.

Related ticket : #30247

2). Improved space usage in computation of distances_distribution of unweighted (di)graphs from O(n^2) to O(n) by avoiding to compute and store into memory the full distance matrix.

Related ticket : #30269


Acknowledgement

First and foremost, I would like to express my sincere gratitude towards Dr. David Coudert, for his dedicated guidance and encouragement throughout the GSoC and prior to it, when I was learning SageMath development. He was very understanding and supportive of the fact that the student might have other academic commitments. He even helped me in optimizing some algorithms and encouraged me to see the bigger picture. Every discussion with him improved my understanding of the project. I have become a lot better at writing clean and efficient codes in Python. Working with SageMath over the summer was a great learning experience and has enhanced my passion for open source. I certainly want to contribute more to open source libraries, and I plan to continue working with SageMath.

And most importantly, I would also like to thank the people behind Google Summer of Code. I had a delightful experience working in GSoC 2020.


References

  1. Feodor Dragan, Michel Habib, Laurent Viennot. “Revisiting Radius, Diameter, and all Eccentricity Computation in Graphs through Certificates”.

  2. Broder, A.Z., Kumar, R., Maghoul, F., Raghavan, P., Rajagopalan, S., Stata, R., Tomkins, A., Wiener, J.L.: Graph structure in the web. Computer Networks 33(1-6), 309–320 (2000)

  3. Pierluigi Crescenzi, Roberto Grossi, Leonardo Lanzi, and Andrea Marino.“On computing the diameter of real-world directed (weighted) graphs”. In Proceedings of the 11th International Symposium on Experimental Algorithms(SEA), pages 99–110, 2012.