Here is a possible algorithm to select only the nodes with angle brackets at the outer edges:
- Scan the input graph and, for each node, check if it has any incoming or outgoing edges.
- For nodes with no incoming or outgoing edges, check if their label (if any) starts and ends with angle brackets ("<" and ">"). If so, mark them as "outer" nodes.
- For all other nodes with incoming or outgoing edges, mark them as "inner" nodes.
- Return the set of "outer" nodes.
Note: This algorithm assumes that the input graph is a directed graph, where edges have a direction (from a source node to a target node). If the graph is undirected, some modifications may be necessary.