class Edge:
	def __init__(self, start, end, directed, weight):
		self.start = start
		self.end = end
		self.directed = directed
		self.weight = weight


def format_edges(weighted_endpoints, directed = False):
	"""
	Format given weights and endpoints of E edges for use by graph algorithms

	Args:
		weighted_endpoints: A list containing endpoints of the form:
					1. [start vertex, end vertex]
					2. [start vertex, end vertex, weight]

					Example: [[1, 2], [3, 4]]     or [[1, 2, 10], [3, 4, 5]]
			
		directed: Set to True if edges are directed (defaults to undirected edges)

	Returns:
		A list of edges (formatted) to be processed by other algorithms.
		The format for each edge is:
			edge.start - Starting vertex of edge
			edge.end - Ending vertex of edge
			edge.weight - Weight of edge (equals 1 if unweighted)
			edge.directed - Boolean indicating if edge is directed (True) or not (False)

	Time:
		O(E)

	"""
	result = []
	for uv in weighted_endpoints:
		if len(uv) == 2:
			result.append(format_edge(uv[0], uv[1], directed))
		elif len(uv) == 3:
			result.append(format_edge(uv[0], uv[1], directed, uv[2]))

	return result

def format_edge(start, end, directed = False, weight = 1):
	return Edge(start, end, directed, weight)