<｜begin▁of▁sentence｜>### Instruction:
Given a weighted undirected graph with nodes (0, 1, 2, 3) and edges [0-1, 1-2, 0-2, 2-3] having weights [1, 3, 2, 4] respectively, can you find the shortest path from vertex 0 to vertex 3 using the A-Star algorithm with a heuristic function that considers the weights of the edges?
### Response:
import igraph as ig

# Create a graph with weighted edges
g = ig.Graph(edges=[(0,1), (1,2), (0,2), (2,3)], directed=False)
g.es['weight'] = [1, 3, 2, 4]

# Define a heuristic function considering the 'weight' attribute
def heuristic(graph, vertex1, vertex2):
    return abs(graph.vs[vertex1]['weight'] - graph.vs[vertex2]['weight'])

# Calculate the shortest path using A* algorithm
path = g.get_shortest_paths_astar(0, 3, weights='weight', heuristic_func=heuristic)

# Print the shortest path
print('Shortest path (A*):', path)
<|EOT|>
