To understand the formation mechanism of magnetic moments at the edges of graphitic fragments, we carry out first-principles density-functional calculations for the electronic and magnetic structures of graphitic fragments with various spin and geometric configurations. We find that interedge and interlayer interactions between the localized moments can be explained in terms of interactions between the magnetic tails of the edge-localized states. In addition, the dihydrogenated edge states as well as Fe ad-atoms at the edge are studied in regard to the magnetic order and proximity effects.