implement segment graph