File:Gabriel graph.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 600 × 600 pixels, file size: 63 KB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: The Gabriel graph of 100 random points
    Date
    Source Own work
    Author David Eppstein
    SVG development
    InfoField
     The SVG code is valid.
     This graph was created with Python.
    Source code
    InfoField

    Python code

    // This image was created with the following Python source code and then recolored and converted to SVG in Adobe Illustrator.
    
    from pyx import canvas,path,color
    from math import *
    from random import seed,random
    seed(12345)
     
    npoints = 100
    radius = 0.05
    exclusion = 0.2     # prevent points from being too close
    scale = 5
    
    def dist2(p,q):
        return (p[0]-q[0])**2 + (p[1]-q[1])**2
     
    points = []
    while len(points) < 100:
        p = (random()*scale,random()*scale)
        if points:
            nn = min(dist2(p,q)**0.5 for q in points)
            if nn < exclusion:
                continue
        points.append(p)
    
    def neighbors(p,q):
        c = ((p[0]+q[0])/2,(p[1]+q[1])/2)
        dd = dist2(p,c)
        for r in points:
            if r != p and r != q and dist2(r,c) < dd:
                return False
        return True
     
    c = canvas.canvas()
     
    def edge(p,q):
        c.stroke(path.line(p[0],p[1],q[0],q[1]),
                 [color.rgb.black])
     
    def point(p):
        c.fill(path.circle(p[0],p[1],radius),[color.rgb.red])
     
    for p in points:
        for q in points:
            if p < q and neighbors(p,q):
                edge(p,q)
     
    for p in points:
        point(p)
     
    c.writePDFfile("Gabriel_graph")
    

    Licensing

    Public domain I, the copyright holder of this work, release this work into the public domain. This applies worldwide.
    In some countries this may not be legally possible; if so:
    I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

    Captions

    Add a one-line explanation of what this file represents

    Items portrayed in this file

    depicts

    6 May 2010

    64,203 byte

    image/svg+xml

    f2e6e0c3b20be3aa7345cdef49dfd4c7ec5c08ba

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current07:03, 7 May 2010Thumbnail for version as of 07:03, 7 May 2010600 × 600 (63 KB)wikimediacommons>David Eppstein{{Information |Description={{en|1=The Gabriel graph of 100 random points}} |Source={{own}} |Author=David Eppstein |Date=2010-05-06 |Permission= |other_versions= }} Category:Computational geometry [[Catego

    There are no pages that use this file.