  The culture of sharing instead of ownership is sharply increasing in
individuals behaviors. Particularly in transportation, concepts of sharing a
ride in either carpooling or ridesharing have been recently adopted. An
efficient optimization approach to match passengers in real-time is the core of
any ridesharing system. In this paper, we model ridesharing as an online
matching problem on general graphs such that passengers do not drive private
cars and use shared taxis. We propose an optimization algorithm to solve it.
The outlined algorithm calculates the optimal waiting time when a passenger
arrives. This leads to a matching with minimal overall overheads while
maximizing the number of partnerships. To evaluate the behavior of our
algorithm, we used NYC taxi real-life data set. Results represent a substantial
reduction in overall overheads.
