Dépôt du be graphe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Arc.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package org.insa.graph;
  2. import java.util.ArrayList;
  3. public class Arc {
  4. // Destination node.
  5. private Node dest;
  6. // Length of the road (in meters).
  7. private int length;
  8. // Road information.
  9. RoadInformation info;
  10. // Segments.
  11. ArrayList<Point> points;
  12. /**
  13. * @param dest
  14. * @param length
  15. * @param roadInformation
  16. * @param points
  17. */
  18. public Arc(Node dest, int length, RoadInformation roadInformation) {
  19. this.dest = dest;
  20. this.length = length;
  21. this.info = roadInformation;
  22. this.points = new ArrayList<Point>();
  23. }
  24. /**
  25. * @param dest
  26. * @param length
  27. * @param roadInformation
  28. * @param points
  29. */
  30. public Arc(Node dest, int length, RoadInformation roadInformation, ArrayList<Point> points) {
  31. this.dest = dest;
  32. this.length = length;
  33. this.info = roadInformation;
  34. this.points = points;
  35. }
  36. /**
  37. * @return Destination node of this arc.
  38. */
  39. public Node getDestination() {
  40. return dest;
  41. }
  42. /**
  43. * @return Length of this arc, in meters.
  44. */
  45. public int getLength() {
  46. return length;
  47. }
  48. /**
  49. * @return Minimum time required to travel this arc, in seconds.
  50. */
  51. public float getMinimumTravelTime() {
  52. return getLength() * 3600f / (info.getMaximumSpeed() * 1000f);
  53. }
  54. /**
  55. * @return Road information for this arc.
  56. */
  57. public RoadInformation getInfo() {
  58. return info;
  59. }
  60. /**
  61. * @return Points representing segments of this arc. This function may return an empty
  62. * ArrayList if the segments are stored in the reversed arc (for two-ways road).
  63. */
  64. public ArrayList<Point> getPoints() {
  65. return points;
  66. }
  67. }