當前位置: 首頁>>代碼示例>>Python>>正文


Python Edge.add_vertex方法代碼示例

本文整理匯總了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]
開發者ID:GeneWu,項目名稱:AHRtelematics,代碼行數:17,代碼來源:rule.py

示例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]
開發者ID:GeneWu,項目名稱:AHRtelematics,代碼行數:17,代碼來源:rule.py

示例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]
開發者ID:GeneWu,項目名稱:AHRtelematics,代碼行數:20,代碼來源:rule.py

示例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]
開發者ID:GeneWu,項目名稱:AHRtelematics,代碼行數:25,代碼來源:rule.py

示例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]
開發者ID:GeneWu,項目名稱:AHRtelematics,代碼行數:26,代碼來源:rule.py


注:本文中的edge.Edge.add_vertex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。