# This is a SAGE function to read lists from a file.
# If a file named "lines" has the lines of a geometry then
# L = ReadListFromFile("PATH_TO_lines") would put those lines in
# the SAGE list L.
def ReadListFromFile(name):
f = open(name)
L = []
for l in f.readlines():
l = l.split()
L.append([int(x) for x in l])
f.close()
return L
L = ReadListFromFile("lines")
# Now we compute the edges of the collinearity graph
edges = []
for l in L:
edges.extend(Combinations(l,2))
T = Graph(edges)
G = T.automorphism_group()
H = gap.DerivedSubgroup(G)
print gap.IsSimpleGroup(H)
print gap.Size(H)
print gap.Size(G)/gap.Size(H)
def IsNearPolygon(graph, lines):
#assuming automorphism group is transitive on vertices
p = graph.vertices()[0]
distance = graph.distance_all_pairs()
def checkNP2(point,line):
dist = sorted([distance[point][x] for x in line])
return dist[0] == dist[1]-1 and dist[1] == dist[-1]
return all([checkNP2(p,l) for l in lines])
print T.is_vertex_transitive()
print IsNearPolygon(T, L)