本文整理汇总了Python中edge.Edge.add_vertex方法的典型用法代码示例。如果您正苦于以下问题:Python Edge.add_vertex方法的具体用法?Python Edge.add_vertex怎么用?Python Edge.add_vertex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edge.Edge
的用法示例。
在下文中一共展示了Edge.add_vertex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PostStopAcc
# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import add_vertex [as 别名]
class PostStopAcc(Rule):
"""classify the trip as high based on maximum of post_stop_acc"""
def __init__(self):
self.name = "PostStopAcc"
self.high_edge = Edge(self.name, "high")
def classify(self, vertex):
max_post_stop_acc = vertex.stop_points[5]
if max_post_stop_acc > 2.0:
self.high_edge.add_vertex(vertex)
return self.high_edge.id
def edges(self):
return [self.high_edge]
示例2: PreStopAcc
# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import add_vertex [as 别名]
class PreStopAcc(Rule):
"""classify the trip as high based on the minimum of pre_stop_acc, which is the maximum of deceleration"""
def __init__(self):
self.name = "PreStopAcc"
self.high_edge = Edge(self.name, "high")
def classify(self, vertex):
min_pre_stop_acc = vertex.stop_points[2]
if min_pre_stop_acc < -3.0:
self.high_edge.add_vertex(vertex)
return self.high_edge.id
def edges(self):
return [self.high_edge]
示例3: MedianSpeedyTurning
# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import add_vertex [as 别名]
class MedianSpeedyTurning(Rule):
"""
classify the trip as high speedy turning based on median
output: high
"""
def __init__(self):
self.name = "MedianSpeedyTurning"
self.high_edge = Edge(self.name, "high")
def classify(self, vertex):
median_speedy_angle = vertex.turning[16]
if median_speedy_angle > 1.0:
self.high_edge.add_vertex(vertex)
return self.high_edge.id
def edges(self):
return [self.high_edge]
示例4: MedianSpeed
# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import add_vertex [as 别名]
class MedianSpeed(Rule):
"""
classify the trip as high / low median speed
output : high , low
"""
def __init__(self):
self.name = "MedianSpeed"
self.high_edge = Edge(self.name, "high")
self.low_edge = Edge(self.name, "low")
def classify(self, vertex):
median_speed = vertex.speed[5]
# high median speed
if median_speed > 25.0:
self.high_edge.add_vertex(vertex)
return self.high_edge.id
if median_speed < 8:
self.low_edge.add_vertex(vertex)
return self.low_edge.id
def edges(self):
return [self.high_edge, self.low_edge]
示例5: TripLengthRule
# 需要导入模块: from edge import Edge [as 别名]
# 或者: from edge.Edge import add_vertex [as 别名]
class TripLengthRule(Rule):
"""
classify the trip as long / short based on time and distance
output: long, short
"""
def __init__(self):
self.name = "TripLengthRule"
self.long_edge = Edge(self.name, "long")
self.short_edge = Edge(self.name, "short")
def classify(self, vertex):
time, distance = vertex.route[0], vertex.route[1]
# long trip
if distance > 1000 and time > 600:
self.long_edge.add_vertex(vertex)
return self.long_edge.id
if distance <= 100:
self.short_edge.add_vertex(vertex)
return self.short_edge.id
def edges(self):
return [self.long_edge, self.short_edge]