FForellin
ผลิตภัณฑ์

คุณสมบัติของโปรแกรม · ป่าแผ่ทั่วต่ำสุด

01

พิจารณา spanning_forest.py เพื่อแยกป่าที่ต้นทุนต่ำสุดจากเส้นทางสั้นสุดหรือการจัดกลุ่มตามใจ.

01

โมเดล

ตั้งค่า endpoint ที่รองรับ OpenAI หรือ Anthropic ด้วย URL หลักและคีย์ API หากจำเป็น ทดสอบการเชื่อมต่อ เซิร์ฟเวอร์โมเดลในเครื่องต้องทำงานอยู่ เครื่องมือระยะไกลอาจส่งข้อมูลแยกต่างหาก

02

โปรเจกต์

เลือกโฟลเดอร์และให้ผู้ช่วยอ่านไฟล์ที่เกี่ยวข้องก่อนแก้ไข ระบุเป้าหมายและขอบเขตของงานให้ชัดเจน

03

การเปลี่ยนแปลง

ตรวจสอบการแก้ไขและผลลัพธ์คำสั่ง รันการตรวจสอบของโปรเจกต์ก่อนยอมรับผล โค้ดที่สร้างขึ้นไม่ได้ผ่านการทดสอบโดยอัตโนมัติ

ป่าแผ่ทั่วต่ำสุด

● ● ●Forellin●
ขั้นตอนการทำงาน · ป่าแผ่ทั่วต่ำสุด ×
def spanning_forest(count, edges):
    if type(count) is not int or not 0 <= count <= 64 or type(edges) is not list or len(edges) > 1024:
        raise ValueError("forest.input")
    ordered = []
    for edge in edges:
        if type(edge) not in (list, tuple) or len(edge) != 3 or any(type(x) is not int for x in edge):
            raise ValueError("forest.edge")
        a, b, weight = edge
        if not 0 <= a < count or not 0 <= b < count or abs(weight) > 10**9:
            raise ValueError("forest.bounds")
        ordered.append((weight, min(a, b), max(a, b)))
    parent = list(range(count))
    def root(node):
        while parent[node] != node:
            parent[node] = parent[parent[node]]
            node = parent[node]
        return node
    selected, total = [], 0
    for weight, a, b in sorted(ordered):
        x, y = root(a), root(b)
        if x != y:
            parent[x] = y
            selected.append((a, b, weight))
            total += weight
    return total, selected
✳ป่าแผ่ทั่วต่ำสุด
✓ การเปลี่ยนแปลงตรวจสอบก่อนนำไปใช้ ↗
ภาพประกอบพื้นที่ทำงาน
พื้นที่เขียนโค้ดด้วย AI

ไอเดียถัดไปเริ่มต้นที่นี่

ดาวน์โหลดสำหรับ Windows ↗